even more dynamic references
This commit is contained in:
parent
c11ef5daba
commit
84590343a2
@ -36,6 +36,7 @@
|
||||
"LuaScript": "require(\"core/DataHelper\")",
|
||||
"LuaScriptState": "[]",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"DataHelper\"}",
|
||||
"Name": "Custom_Tile",
|
||||
"Nickname": "Data Helper",
|
||||
"Snap": true,
|
||||
|
@ -38,6 +38,7 @@
|
||||
"LuaScriptState": "",
|
||||
"MaterialIndex": -1,
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"OptionPanelSource\"}",
|
||||
"MeshIndex": -1,
|
||||
"Name": "Bag",
|
||||
"Nickname": "OptionPanel Source",
|
||||
|
@ -25,6 +25,7 @@
|
||||
"LuaScript": "",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayAreaZone\"}",
|
||||
"Name": "ScriptingTrigger",
|
||||
"Nickname": "",
|
||||
"Snap": true,
|
||||
|
@ -37,6 +37,7 @@
|
||||
"LuaScriptState": "",
|
||||
"MaterialIndex": -1,
|
||||
"MeasureMovement": false,
|
||||
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenSource\"}",
|
||||
"MeshIndex": -1,
|
||||
"Name": "Bag",
|
||||
"Nickname": "Token Source",
|
||||
|
@ -16,7 +16,7 @@ local IGNORE_GUIDS = {
|
||||
"b7b45b", "f182ee", "721ba2",
|
||||
-- bless/curse manager
|
||||
"afa06b", "bd0253", "5933fb",
|
||||
-- stuff on agenda/act playmat
|
||||
-- stuff on mythos area
|
||||
"85c4c6", "4a3aa4", "fea079", "b015d8", "11e0cf", "9f334f", "70b9f6", "0a5a29",
|
||||
-- doom/location token bag
|
||||
"47ffc3", "170f10",
|
||||
@ -28,7 +28,7 @@ local IGNORE_GUIDS = {
|
||||
local IGNORE_TAG = "CleanUpHelper_ignore"
|
||||
|
||||
-- colors and order for following tables
|
||||
local COLORS = { "White", "Orange", "Green", "Red", "Agenda" }
|
||||
local COLORS = { "White", "Orange", "Green", "Red", "Mythos" }
|
||||
|
||||
-- counter GUIDS (4x damage and 4x horror)
|
||||
local DAMAGE_HORROR_GUIDS = {
|
||||
@ -47,7 +47,7 @@ local CLUE_GUIDS = { "d86b7c", "1769ed", "032300", "37be78" }
|
||||
local CLUE_CLICKER_GUIDS = { "db85d6", "3f22e5", "891403", "4111de" }
|
||||
local TRASHCAN_GUIDS = { "147e80", "f7b6c8", "5f896a", "4b8594", "70b9f6" }
|
||||
|
||||
-- values for physics.cast (4 entries for player zones, 5th entry for agenda/act deck, 6th for campaign log)
|
||||
-- values for physics.cast (4 entries for player zones, 5th entry for mythos area, 6th for campaign log)
|
||||
local PHYSICS_POSITION = {
|
||||
{ -54.5, 2, 21 },
|
||||
{ -54.5, 2, -21 },
|
||||
@ -339,12 +339,12 @@ function tidyPlayareaCoroutine()
|
||||
end
|
||||
end
|
||||
|
||||
printToAll("Tidying playermats and agenda mat...", "White")
|
||||
printToAll("Tidying playermats and mythos area...", "White")
|
||||
startLuaCoroutine(self, "tidyPlayerMatCoroutine")
|
||||
return 1
|
||||
end
|
||||
|
||||
-- clean up for the four playermats and the agenda/act playmat
|
||||
-- clean up for the four playermats and the mythos area
|
||||
function tidyPlayerMatCoroutine()
|
||||
for i = 1, 5 do
|
||||
-- only continue for playermat (1-4) if option enabled
|
||||
@ -364,8 +364,10 @@ function tidyPlayerMatCoroutine()
|
||||
local desc_low = string.lower(obj.getDescription())
|
||||
|
||||
-- ignore these elements
|
||||
if not tableContains(IGNORE_GUIDS, obj.getGUID()) and obj.hasTag(IGNORE_TAG) == false and
|
||||
desc_low ~= "chaos bag" and desc_low ~= "action token" then
|
||||
if not tableContains(IGNORE_GUIDS, obj.getGUID())
|
||||
and obj.hasTag(IGNORE_TAG) == false
|
||||
and desc_low ~= "chaos bag"
|
||||
and desc_low ~= "action token" then
|
||||
coroutine.yield(0)
|
||||
trashcan.putObject(obj)
|
||||
|
||||
@ -398,7 +400,7 @@ end
|
||||
-- helper functions
|
||||
---------------------------------------------------------
|
||||
|
||||
-- find objects depending on index (1 to 4 for playermats, 5 for agenda/act playmat, 6 for campaign log)
|
||||
-- find objects depending on index (1 to 4 for playermats, 5 for mythos area, 6 for campaign log)
|
||||
function findObjects(num)
|
||||
return Physics.cast({
|
||||
direction = { 0, 1, 0 },
|
||||
|
@ -15,9 +15,6 @@ local tokenManager = require("core/token/TokenManager")
|
||||
ENCOUNTER_DECK_POS = {-3.93, 1, 5.76}
|
||||
ENCOUNTER_DECK_DISCARD_POSITION = {-3.85, 1, 10.38}
|
||||
|
||||
-- GUID of data helper
|
||||
DATA_HELPER_GUID = "708279"
|
||||
|
||||
-- GUIDs that will not be interactable (e.g. parts of the table)
|
||||
local NOT_INTERACTABLE = {
|
||||
"6161b4", -- Decoration-Map
|
||||
@ -32,6 +29,7 @@ local NOT_INTERACTABLE = {
|
||||
"975c39", -- vertical border right
|
||||
}
|
||||
|
||||
local DATA_HELPER
|
||||
local chaosTokens = {}
|
||||
local chaosTokensLastMat = nil
|
||||
local bagSearchers = {}
|
||||
@ -99,14 +97,6 @@ ID_URL_MAP = {
|
||||
-- data for chaos token stat tracker
|
||||
---------------------------------------------------------
|
||||
|
||||
local MAT_GUID_TO_COLOR = {
|
||||
["Overall"] = "Overall",
|
||||
["8b081b"] = "White",
|
||||
["bd0ff4"] = "Orange",
|
||||
["383d8b"] = "Green",
|
||||
["0840d5"] = "Red"
|
||||
}
|
||||
|
||||
local tokenDrawingStats = {
|
||||
["Overall"] = {},
|
||||
["8b081b"] = {},
|
||||
@ -137,6 +127,7 @@ function onLoad(savedData)
|
||||
if obj ~= nil then obj.interactable = false end
|
||||
end
|
||||
|
||||
DATA_HELPER = getObjectFromMemo({matColor = "Mythos", type = "DataHelper"})
|
||||
resetChaosTokenStatTracker()
|
||||
getModVersion()
|
||||
math.randomseed(os.time())
|
||||
@ -191,8 +182,8 @@ 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 = {}
|
||||
if matColor == nil then return objList end
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
@ -205,10 +196,11 @@ function getObjectsForMatColor(matColor)
|
||||
return objList
|
||||
end
|
||||
|
||||
-- gets all objects that match the provided type
|
||||
-- gets all objects that match the provided type, sorted by owner
|
||||
---@param type String Object to look for (usually name without spaces)
|
||||
function getObjectForType(type)
|
||||
if type == nil then return nil end
|
||||
function getObjectsForType(type)
|
||||
local objList = {}
|
||||
if type == nil then return objList end
|
||||
for _, obj in ipairs(getObjects()) do
|
||||
local memo = obj.getMemo()
|
||||
if memo then
|
||||
@ -349,7 +341,11 @@ function handleStatTrackerClick(_, _, isRightClick)
|
||||
playerColor = "White"
|
||||
playerName = "Overall"
|
||||
else
|
||||
playerColor = playmatApi.getPlayerColor(MAT_GUID_TO_COLOR[key])
|
||||
-- get mat color from memo
|
||||
local mat = getObjectFromGUID(key)
|
||||
local decoded = JSON.decode(mat.getMemo())
|
||||
local matColor = decoded.matColor
|
||||
playerColor = playmatApi.getPlayerColor(matColor)
|
||||
playerName = Player[playerColor].steam_name or playerColor
|
||||
|
||||
local playerSquidCount = personalStats["Auto-fail"]
|
||||
@ -499,7 +495,7 @@ function fillContainer(args)
|
||||
end
|
||||
|
||||
function getDataValue(storage, key)
|
||||
local data = getObjectFromGUID(DATA_HELPER_GUID).getTable(storage)
|
||||
local data = DATA_HELPER.getTable(storage)
|
||||
if data ~= nil then
|
||||
local value = data[key]
|
||||
if value ~= nil then
|
||||
@ -996,7 +992,7 @@ end
|
||||
---@param rotation Table Desired rotation of the object (defaults to object's rotation)
|
||||
---@param color String Matcolor this object is spawned for to set memo
|
||||
function spawnHelperObject(name, position, rotation, color)
|
||||
local sourceBag = getObjectFromGUID("830bd0")
|
||||
local sourceBag = getObjectFromMemo({matColor = "Mythos", type = "OptionPanelSource"})
|
||||
|
||||
-- error handling for missing sourceBag
|
||||
if not sourceBag then
|
||||
|
@ -20,11 +20,7 @@ local isReshuffling = false
|
||||
-- scenario metadata
|
||||
local currentScenario, useFrontData, tokenData
|
||||
|
||||
-- GUID of data helper
|
||||
local DATA_HELPER_GUID = "708279"
|
||||
|
||||
local TRASHCAN
|
||||
local TRASHCAN_GUID = "70b9f6"
|
||||
local TRASHCAN, DATA_HELPER
|
||||
|
||||
-- we use this to turn off collision handling until onLoad() is complete
|
||||
local collisionEnabled = false
|
||||
@ -36,7 +32,8 @@ function onLoad(saveState)
|
||||
useFrontData = loadedState.useFrontData or true
|
||||
tokenData = loadedState.tokenData or {}
|
||||
end
|
||||
TRASHCAN = getObjectFromGUID(TRASHCAN_GUID)
|
||||
TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"})
|
||||
DATA_HELPER = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"})
|
||||
collisionEnabled = true
|
||||
end
|
||||
|
||||
@ -153,7 +150,7 @@ function actualEncounterCardDraw(card, params)
|
||||
local faceUpRotation = 0
|
||||
if not params.alwaysFaceUp then
|
||||
local metadata = JSON.decode(card.getGMNotes()) or {}
|
||||
if metadata.hidden or getObjectFromGUID(DATA_HELPER_GUID).call('checkHiddenCard', card.getName()) then
|
||||
if metadata.hidden or DATA_HELPER.call('checkHiddenCard', card.getName()) then
|
||||
faceUpRotation = 180
|
||||
end
|
||||
end
|
||||
|
@ -1,15 +1,16 @@
|
||||
do
|
||||
local MythosAreaApi = {}
|
||||
local MYTHOS_AREA_GUID = "9f334f"
|
||||
|
||||
-- returns the chaos token metadata (if provided through scenario reference card)
|
||||
MythosAreaApi.returnTokenData = function()
|
||||
return getObjectFromGUID(MYTHOS_AREA_GUID).call("returnTokenData")
|
||||
local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"})
|
||||
return MythosArea.call("returnTokenData")
|
||||
end
|
||||
|
||||
|
||||
-- draw an encounter card to the requested position/rotation
|
||||
MythosAreaApi.drawEncounterCard = function(pos, rotY, alwaysFaceUp)
|
||||
getObjectFromGUID(MYTHOS_AREA_GUID).call("drawEncounterCard", {
|
||||
local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"})
|
||||
MythosArea.call("drawEncounterCard", {
|
||||
pos = pos,
|
||||
rotY = rotY,
|
||||
alwaysFaceUp = alwaysFaceUp
|
||||
|
@ -44,8 +44,6 @@ local LOC_LINK_EXCLUDE_SCENARIOS = {
|
||||
}
|
||||
|
||||
local tokenManager = require("core/token/TokenManager")
|
||||
local INVESTIGATOR_COUNTER_GUID = "f182ee"
|
||||
local PLAY_AREA_ZONE_GUID = "a2f932"
|
||||
|
||||
local clueData = {}
|
||||
local spawnedLocationGUIDs = {}
|
||||
@ -508,7 +506,7 @@ function shiftContentsRight(playerColor)
|
||||
end
|
||||
|
||||
function shiftContents(playerColor, direction)
|
||||
local zone = getObjectFromGUID(PLAY_AREA_ZONE_GUID)
|
||||
local zone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"})
|
||||
if not zone then
|
||||
broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red")
|
||||
return
|
||||
|
@ -119,15 +119,10 @@ do
|
||||
["supply"] = 7
|
||||
}
|
||||
|
||||
-- Source for tokens
|
||||
local TOKEN_SOURCE_GUID = "124381"
|
||||
|
||||
-- Table of data extracted from the token source bag, keyed by the Memo on each token which
|
||||
-- should match the token type keys ("resource", "clue", etc)
|
||||
local tokenTemplates
|
||||
|
||||
local DATA_HELPER_GUID = "708279"
|
||||
|
||||
local playerCardData
|
||||
local locationData
|
||||
|
||||
@ -340,7 +335,7 @@ do
|
||||
return
|
||||
end
|
||||
tokenTemplates = { }
|
||||
local tokenSource = getObjectFromGUID(TOKEN_SOURCE_GUID)
|
||||
local tokenSource = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSource"})
|
||||
for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do
|
||||
local tokenName = tokenTemplate.Memo
|
||||
tokenTemplates[tokenName] = tokenTemplate
|
||||
@ -352,7 +347,7 @@ do
|
||||
if playerCardData ~= nil then
|
||||
return
|
||||
end
|
||||
local dataHelper = getObjectFromGUID(DATA_HELPER_GUID)
|
||||
local dataHelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"})
|
||||
playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')
|
||||
locationData = dataHelper.getTable('LOCATIONS_DATA')
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user