From f6d0a996742beaa7c2ef3c9f865f9bd94b2126fc Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 11:11:38 +0200 Subject: [PATCH 01/76] object metadata addition to memo --- objects/ClueCounter.032300.json | 1 + objects/ClueCounter.1769ed.json | 1 + objects/ClueCounter.37be78.json | 1 + objects/ClueCounter.d86b7c.json | 1 + objects/Clues.3f22e5.json | 1 + objects/Clues.4111de.json | 1 + objects/Clues.891403.json | 1 + objects/Clues.db85d6.json | 1 + objects/Damage.1f5a0a.json | 1 + objects/Damage.591a45.json | 1 + objects/Damage.e64eec.json | 1 + objects/Damage.eb08d6.json | 1 + objects/Horror.0257d9.json | 1 + objects/Horror.468e88.json | 1 + objects/Horror.7b5729.json | 1 + objects/Horror.beb964.json | 1 + objects/InvestigatorSkillTracker.af7ed7.json | 1 + objects/InvestigatorSkillTracker.b4a5f7.json | 1 + objects/InvestigatorSkillTracker.e598c2.json | 1 + objects/InvestigatorSkillTracker.e74881.json | 1 + objects/Playermat1White.8b081b.json | 1 + objects/Playermat2Orange.bd0ff4.json | 1 + objects/Playermat3Green.383d8b.json | 1 + objects/Playermat4Red.0840d5.json | 1 + objects/Resources.4406f0.json | 1 + objects/Resources.816d84.json | 1 + objects/Resources.a4b60d.json | 1 + objects/Resources.cd15ac.json | 1 + src/core/Global.ttslua | 14 +++++++++----- 29 files changed, 37 insertions(+), 5 deletions(-) diff --git a/objects/ClueCounter.032300.json b/objects/ClueCounter.032300.json index 71211083..b3453154 100644 --- a/objects/ClueCounter.032300.json +++ b/objects/ClueCounter.032300.json @@ -45,6 +45,7 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.1769ed.json b/objects/ClueCounter.1769ed.json index 914b6298..ef8f9040 100644 --- a/objects/ClueCounter.1769ed.json +++ b/objects/ClueCounter.1769ed.json @@ -45,6 +45,7 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.37be78.json b/objects/ClueCounter.37be78.json index 5b7fcb52..d43058e5 100644 --- a/objects/ClueCounter.37be78.json +++ b/objects/ClueCounter.37be78.json @@ -45,6 +45,7 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.d86b7c.json b/objects/ClueCounter.d86b7c.json index 8beb0fc8..ce05c108 100644 --- a/objects/ClueCounter.d86b7c.json +++ b/objects/ClueCounter.d86b7c.json @@ -45,6 +45,7 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/Clues.3f22e5.json b/objects/Clues.3f22e5.json index 17a50489..18ea7e44 100644 --- a/objects/Clues.3f22e5.json +++ b/objects/Clues.3f22e5.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.4111de.json b/objects/Clues.4111de.json index 97c69558..01eac58b 100644 --- a/objects/Clues.4111de.json +++ b/objects/Clues.4111de.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.891403.json b/objects/Clues.891403.json index 32174201..64b11f2e 100644 --- a/objects/Clues.891403.json +++ b/objects/Clues.891403.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.db85d6.json b/objects/Clues.db85d6.json index 902a38f5..2a9177df 100644 --- a/objects/Clues.db85d6.json +++ b/objects/Clues.db85d6.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Damage.1f5a0a.json b/objects/Damage.1f5a0a.json index 38534af1..3e21c9ac 100644 --- a/objects/Damage.1f5a0a.json +++ b/objects/Damage.1f5a0a.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.591a45.json b/objects/Damage.591a45.json index b1c402b9..b8f9f6b4 100644 --- a/objects/Damage.591a45.json +++ b/objects/Damage.591a45.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.e64eec.json b/objects/Damage.e64eec.json index 99f89b60..e82254b7 100644 --- a/objects/Damage.e64eec.json +++ b/objects/Damage.e64eec.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.eb08d6.json b/objects/Damage.eb08d6.json index 39eab22d..f4a3ea15 100644 --- a/objects/Damage.eb08d6.json +++ b/objects/Damage.eb08d6.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Horror.0257d9.json b/objects/Horror.0257d9.json index f933c101..5be90941 100644 --- a/objects/Horror.0257d9.json +++ b/objects/Horror.0257d9.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.468e88.json b/objects/Horror.468e88.json index b6a6cb0b..620826ca 100644 --- a/objects/Horror.468e88.json +++ b/objects/Horror.468e88.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.7b5729.json b/objects/Horror.7b5729.json index 973828d6..c8214fa4 100644 --- a/objects/Horror.7b5729.json +++ b/objects/Horror.7b5729.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.beb964.json b/objects/Horror.beb964.json index 9564ddac..77c029f6 100644 --- a/objects/Horror.beb964.json +++ b/objects/Horror.beb964.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.af7ed7.json b/objects/InvestigatorSkillTracker.af7ed7.json index 8e320a3d..ed05ca40 100644 --- a/objects/InvestigatorSkillTracker.af7ed7.json +++ b/objects/InvestigatorSkillTracker.af7ed7.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.b4a5f7.json b/objects/InvestigatorSkillTracker.b4a5f7.json index cbf2123d..dd711c4f 100644 --- a/objects/InvestigatorSkillTracker.b4a5f7.json +++ b/objects/InvestigatorSkillTracker.b4a5f7.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.e598c2.json b/objects/InvestigatorSkillTracker.e598c2.json index c82d17bf..91a44681 100644 --- a/objects/InvestigatorSkillTracker.e598c2.json +++ b/objects/InvestigatorSkillTracker.e598c2.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.e74881.json b/objects/InvestigatorSkillTracker.e74881.json index aad443c7..5d5a57b5 100644 --- a/objects/InvestigatorSkillTracker.e74881.json +++ b/objects/InvestigatorSkillTracker.e74881.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index 0cd532bf..4fc6db15 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -346,6 +346,7 @@ "LuaScriptState_path": "Playermat1White.8b081b.luascriptstate", "LuaScript_path": "Playermat1White.8b081b.ttslua", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", "Nickname": "Playermat 1: White", "Snap": true, diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index ccc4720a..1b90fc2d 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -346,6 +346,7 @@ "LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate", "LuaScript_path": "Playermat2Orange.bd0ff4.ttslua", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", "Nickname": "Playermat 2: Orange", "Snap": true, diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index 82f2760f..b5a1f585 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -346,6 +346,7 @@ "LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate", "LuaScript_path": "Playermat3Green.383d8b.ttslua", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", "Nickname": "Playermat 3: Green", "Snap": true, diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index aeb7a709..0d694a1a 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -346,6 +346,7 @@ "LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate", "LuaScript_path": "Playermat4Red.0840d5.ttslua", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", "Nickname": "Playermat 4: Red", "Snap": true, diff --git a/objects/Resources.4406f0.json b/objects/Resources.4406f0.json index d0ad1b7c..27ee263a 100644 --- a/objects/Resources.4406f0.json +++ b/objects/Resources.4406f0.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.816d84.json b/objects/Resources.816d84.json index de7dc10a..56ea1b61 100644 --- a/objects/Resources.816d84.json +++ b/objects/Resources.816d84.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.a4b60d.json b/objects/Resources.a4b60d.json index 16acd881..16f3cbfb 100644 --- a/objects/Resources.a4b60d.json +++ b/objects/Resources.a4b60d.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.cd15ac.json b/objects/Resources.cd15ac.json index d87f1ff2..d98591a4 100644 --- a/objects/Resources.cd15ac.json +++ b/objects/Resources.cd15ac.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0ac0f349..96c45de3 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -893,7 +893,7 @@ function applyOptionPanelChange(id, state) for i, color in ipairs(MAT_COLORS) do local pos = playmatApi.transformLocalPosition({0.05, 0, -1.182}, color) local rot = playmatApi.returnRotation(color) - optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot) + optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot, color) end -- option: Show search assistant for each player @@ -901,7 +901,7 @@ function applyOptionPanelChange(id, state) for i, color in ipairs(MAT_COLORS) do local pos = playmatApi.transformLocalPosition({-0.3, 0, -1.182}, color) local rot = playmatApi.returnRotation(color) - optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot) + optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot, color) end -- option: Show attachment helper @@ -928,12 +928,12 @@ end ---@param position Vector Position of the object (where it will spawn) ---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0}) ---@return. GUID of the spawnedObj (or nil if object was removed) -function spawnOrRemoveHelper(state, name, position, rotation) +function spawnOrRemoveHelper(state, name, position, rotation, color) if (type(state) == "table" and #state == 0) then return removeHelperObject(name) elseif state then Player.getPlayers()[1].pingTable(position) - return spawnHelperObject(name, position, rotation).getGUID() + return spawnHelperObject(name, position, rotation, color).getGUID() else return removeHelperObject(name) end @@ -942,7 +942,9 @@ end -- copies the specified tool (by name) from the option panel source bag ---@param name String Name of the object that should be copied ---@param position Table Desired position of the object -function spawnHelperObject(name, position, rotation) +---@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") -- error handling for missing sourceBag @@ -961,6 +963,8 @@ function spawnHelperObject(name, position, rotation) 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) + spawnTable.data["Memo"] = "{\"matColor\":\"" .. color .. "\",\"type\":\"" .. name:gsub("%s+", "") .. "\"}" spawnTable.callback_function = function(spawnedObj) Wait.time(function() spawnedObj.setLock(true) end, 2) end From 4c425aea213db14bc4514f978adc446afb8f6764 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 11:15:44 +0200 Subject: [PATCH 02/76] added metadata to trash --- objects/Trash.147e80.json | 1 + objects/Trash.4b8594.json | 1 + objects/Trash.5f896a.json | 1 + objects/Trash.70b9f6.json | 1 + objects/Trash.f7b6c8.json | 1 + 5 files changed, 5 insertions(+) diff --git a/objects/Trash.147e80.json b/objects/Trash.147e80.json index 493eeef7..7d71eb3a 100644 --- a/objects/Trash.147e80.json +++ b/objects/Trash.147e80.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.4b8594.json b/objects/Trash.4b8594.json index b3d8e954..d227616b 100644 --- a/objects/Trash.4b8594.json +++ b/objects/Trash.4b8594.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.5f896a.json b/objects/Trash.5f896a.json index c0aed51b..83f9df28 100644 --- a/objects/Trash.5f896a.json +++ b/objects/Trash.5f896a.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.70b9f6.json b/objects/Trash.70b9f6.json index 9157562a..0ca6bbea 100644 --- a/objects/Trash.70b9f6.json +++ b/objects/Trash.70b9f6.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.f7b6c8.json b/objects/Trash.f7b6c8.json index a5fc05c6..1923f48f 100644 --- a/objects/Trash.f7b6c8.json +++ b/objects/Trash.f7b6c8.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", From 550c9582759296e271de7e8ec782d74719649497 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 11:17:22 +0200 Subject: [PATCH 03/76] added metadata to hand zones --- objects/HandTrigger.0285cc.json | 1 + objects/HandTrigger.5fe087.json | 1 + objects/HandTrigger.a70eee.json | 1 + objects/HandTrigger.be2f17.json | 1 + 4 files changed, 4 insertions(+) diff --git a/objects/HandTrigger.0285cc.json b/objects/HandTrigger.0285cc.json index d8eff7f5..735a2aa8 100644 --- a/objects/HandTrigger.0285cc.json +++ b/objects/HandTrigger.0285cc.json @@ -26,6 +26,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Green\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.5fe087.json b/objects/HandTrigger.5fe087.json index 0ea988e6..b4867966 100644 --- a/objects/HandTrigger.5fe087.json +++ b/objects/HandTrigger.5fe087.json @@ -26,6 +26,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Orange\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.a70eee.json b/objects/HandTrigger.a70eee.json index 9fcb112a..d4713ce7 100644 --- a/objects/HandTrigger.a70eee.json +++ b/objects/HandTrigger.a70eee.json @@ -26,6 +26,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"White\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.be2f17.json b/objects/HandTrigger.be2f17.json index ac40365c..19dbb68d 100644 --- a/objects/HandTrigger.be2f17.json +++ b/objects/HandTrigger.be2f17.json @@ -26,6 +26,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Red\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, From 889f0af13f416fe1bf6e05083f08c341b16a95ab Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 12:08:54 +0200 Subject: [PATCH 04/76] made object reference dynamic --- modsettings/ComponentTags.json | 4 -- objects/BlessCurseManager.5933fb.json | 1 + objects/MythosArea.9f334f.json | 1 + objects/Playarea.721ba2.json | 1 + objects/Playermat1White.8b081b.json | 2 +- objects/Playermat1White.8b081b.ttslua | 11 --- objects/Playermat2Orange.bd0ff4.json | 2 +- objects/Playermat2Orange.bd0ff4.ttslua | 11 --- objects/Playermat3Green.383d8b.json | 2 +- objects/Playermat3Green.383d8b.ttslua | 11 --- objects/Playermat4Red.0840d5.json | 2 +- objects/Playermat4Red.0840d5.ttslua | 11 --- objects/TokenArranger.022907.json | 4 +- objects/VictoryDisplay.6ccd6d.json | 1 + src/accessories/TokenArrangerApi.ttslua | 23 ++++++- src/chaosbag/BlessCurseManagerApi.ttslua | 34 ++++++++-- src/playermat/Playmat.ttslua | 86 ++++++++++++------------ src/playermat/PlaymatApi.ttslua | 74 ++++++++++---------- 18 files changed, 138 insertions(+), 143 deletions(-) delete mode 100644 objects/Playermat1White.8b081b.ttslua delete mode 100644 objects/Playermat2Orange.bd0ff4.ttslua delete mode 100644 objects/Playermat3Green.383d8b.ttslua delete mode 100644 objects/Playermat4Red.0840d5.ttslua diff --git a/modsettings/ComponentTags.json b/modsettings/ComponentTags.json index 8d28dfae..83a638b1 100644 --- a/modsettings/ComponentTags.json +++ b/modsettings/ComponentTags.json @@ -83,10 +83,6 @@ { "displayed": "CameraZoom_ignore", "normalized": "camerazoom_ignore" - }, - { - "displayed": "TokenArranger", - "normalized": "tokenarranger" } ] } diff --git a/objects/BlessCurseManager.5933fb.json b/objects/BlessCurseManager.5933fb.json index ae7809ce..c7325804 100644 --- a/objects/BlessCurseManager.5933fb.json +++ b/objects/BlessCurseManager.5933fb.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"chaosbag/BlessCurseManager\")", "LuaScriptState": "false", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"BlessCurseManager\"}", "Name": "Custom_Token", "Nickname": "Bless/Curse Manager", "Snap": true, diff --git a/objects/MythosArea.9f334f.json b/objects/MythosArea.9f334f.json index 83ba39e6..734c5d92 100644 --- a/objects/MythosArea.9f334f.json +++ b/objects/MythosArea.9f334f.json @@ -62,6 +62,7 @@ "LuaScript": "require(\"core/MythosArea\")", "LuaScriptState": "{\"currentScenario\":\"\",\"tokenData\":[],\"useFrontData\":true}", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"MythosArea\"}", "Name": "Custom_Tile", "Nickname": "Mythos Area", "Snap": true, diff --git a/objects/Playarea.721ba2.json b/objects/Playarea.721ba2.json index 0bbd9af2..74caeab4 100644 --- a/objects/Playarea.721ba2.json +++ b/objects/Playarea.721ba2.json @@ -973,6 +973,7 @@ "LuaScript": "require(\"core/PlayArea\")", "LuaScriptState": "{\"trackedLocations\":[]}", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayArea\"}", "Name": "Custom_Token", "Nickname": "Playarea", "Snap": true, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index 4fc6db15..ce714318 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -343,8 +343,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, + "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat1White.8b081b.luascriptstate", - "LuaScript_path": "Playermat1White.8b081b.ttslua", "MeasureMovement": false, "Memo": "{\"matColor\":\"White\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", diff --git a/objects/Playermat1White.8b081b.ttslua b/objects/Playermat1White.8b081b.ttslua deleted file mode 100644 index 6d2d842f..00000000 --- a/objects/Playermat1White.8b081b.ttslua +++ /dev/null @@ -1,11 +0,0 @@ ---------------------------------------------------------- --- specific setup (different for each playmat) ---------------------------------------------------------- - -TRASHCAN_GUID = "147e80" -STAT_TRACKER_GUID = "e598c2" -RESOURCE_COUNTER_GUID = "4406f0" -CLUE_COUNTER_GUID = "d86b7c" -CLUE_CLICKER_GUID = "db85d6" - -require("playermat/Playmat") diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index 1b90fc2d..d0bc1be6 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -343,8 +343,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, + "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate", - "LuaScript_path": "Playermat2Orange.bd0ff4.ttslua", "MeasureMovement": false, "Memo": "{\"matColor\":\"Orange\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", diff --git a/objects/Playermat2Orange.bd0ff4.ttslua b/objects/Playermat2Orange.bd0ff4.ttslua deleted file mode 100644 index 4530453c..00000000 --- a/objects/Playermat2Orange.bd0ff4.ttslua +++ /dev/null @@ -1,11 +0,0 @@ ---------------------------------------------------------- --- specific setup (different for each playmat) ---------------------------------------------------------- - -TRASHCAN_GUID = "f7b6c8" -STAT_TRACKER_GUID = "b4a5f7" -RESOURCE_COUNTER_GUID = "816d84" -CLUE_COUNTER_GUID = "1769ed" -CLUE_CLICKER_GUID = "3f22e5" - -require("playermat/Playmat") diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index b5a1f585..4f9a6292 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -343,8 +343,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, + "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate", - "LuaScript_path": "Playermat3Green.383d8b.ttslua", "MeasureMovement": false, "Memo": "{\"matColor\":\"Green\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", diff --git a/objects/Playermat3Green.383d8b.ttslua b/objects/Playermat3Green.383d8b.ttslua deleted file mode 100644 index 818bd09f..00000000 --- a/objects/Playermat3Green.383d8b.ttslua +++ /dev/null @@ -1,11 +0,0 @@ ---------------------------------------------------------- --- specific setup (different for each playmat) ---------------------------------------------------------- - -TRASHCAN_GUID = "5f896a" -STAT_TRACKER_GUID = "af7ed7" -RESOURCE_COUNTER_GUID = "cd15ac" -CLUE_COUNTER_GUID = "032300" -CLUE_CLICKER_GUID = "891403" - -require("playermat/Playmat") diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 0d694a1a..b02587ef 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -343,8 +343,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": true, + "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate", - "LuaScript_path": "Playermat4Red.0840d5.ttslua", "MeasureMovement": false, "Memo": "{\"matColor\":\"Red\",\"type\":\"Playermat\"}", "Name": "Custom_Tile", diff --git a/objects/Playermat4Red.0840d5.ttslua b/objects/Playermat4Red.0840d5.ttslua deleted file mode 100644 index 6c0fb70f..00000000 --- a/objects/Playermat4Red.0840d5.ttslua +++ /dev/null @@ -1,11 +0,0 @@ ---------------------------------------------------------- --- specific setup (different for each playmat) ---------------------------------------------------------- - -TRASHCAN_GUID = "4b8594" -STAT_TRACKER_GUID = "e74881" -RESOURCE_COUNTER_GUID = "a4b60d" -CLUE_COUNTER_GUID = "37be78" -CLUE_CLICKER_GUID = "4111de" - -require("playermat/Playmat") diff --git a/objects/TokenArranger.022907.json b/objects/TokenArranger.022907.json index ec5c2a4a..4fb6d2fc 100644 --- a/objects/TokenArranger.022907.json +++ b/objects/TokenArranger.022907.json @@ -36,13 +36,11 @@ "LuaScript": "require(\"accessories/TokenArranger\")", "LuaScriptState_path": "TokenArranger.022907.luascriptstate", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenArranger\"}", "Name": "Custom_Token", "Nickname": "Token Arranger", "Snap": true, "Sticky": true, - "Tags": [ - "TokenArranger" - ], "Tooltip": true, "Transform": { "posX": -42.3, diff --git a/objects/VictoryDisplay.6ccd6d.json b/objects/VictoryDisplay.6ccd6d.json index 622ccfd8..7834f0a9 100644 --- a/objects/VictoryDisplay.6ccd6d.json +++ b/objects/VictoryDisplay.6ccd6d.json @@ -158,6 +158,7 @@ "LuaScript": "require(\"core/VictoryDisplay\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"VictoryDisplay\"}", "Name": "Custom_Token", "Nickname": "Victory Display", "Snap": false, diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 47afb77f..4538431d 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -1,11 +1,32 @@ 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 = getObjectsWithTag("TokenArranger")[1] + local tokenArranger = getObjectFromMemo("Mythos", "TokenArranger") if tokenArranger ~= nil then tokenArranger.call(functionName, argument) end diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index 694e98b2..87dfb60b 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,10 +1,30 @@ do local BlessCurseManagerApi = {} - local MANAGER_GUID = "5933fb" + + -- 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 = getObjectFromGUID(MANAGER_GUID) + local BlessCurseManager = getObjectFromMemo("Mythos", "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) @@ -12,30 +32,30 @@ do -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.sealedToken = function(type, guid) - getObjectFromGUID(MANAGER_GUID).call("sealedToken", { type = type, guid = guid }) + getObjectFromMemo("Mythos", "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) - getObjectFromGUID(MANAGER_GUID).call("releasedToken", { type = type, guid = guid }) + getObjectFromMemo("Mythos", "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) - getObjectFromGUID(MANAGER_GUID).call("broadcastStatus", playerColor) + getObjectFromMemo("Mythos", "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) - getObjectFromGUID(MANAGER_GUID).call("doRemove", playerColor) + getObjectFromMemo("Mythos", "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) - getObjectFromGUID(MANAGER_GUID).call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) + getObjectFromMemo("Mythos", "BlessCurseManager").call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) end return BlessCurseManagerApi diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 91b1b94c..a36c554a 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -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 TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER +local MATCOLOR, TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER local isDrawButtonVisible = false -- global variable to report "Dream-Enhancing Serum" status @@ -79,9 +79,12 @@ end function onLoad(save_state) self.interactable = DEBUG - TRASHCAN = getObjectFromGUID(TRASHCAN_GUID) - STAT_TRACKER = getObjectFromGUID(STAT_TRACKER_GUID) - RESOURCE_COUNTER = getObjectFromGUID(RESOURCE_COUNTER_GUID) + -- 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") -- button creation for i = 1, 6 do @@ -209,6 +212,35 @@ function doNotReady(card) return card.getVar("do_not_ready") or false end +-- rounds a number to the specified amount of decimal places +---@param num Number Initial value +---@param numDecimalPlaces Number Amount of decimal places +function round(num, numDecimalPlaces) + local mult = 10^(numDecimalPlaces or 0) + 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 --------------------------------------------------------- @@ -570,32 +602,8 @@ 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) - local HAND_ZONE_GUIDS = { - "a70eee", -- White - "5fe087", -- Orange - "0285cc", -- Green - "be2f17" -- Red - } - local index - local startPos = self.getPosition() - - -- get respective hand zone by position - if startPos.x < -42 then - if startPos.z > 0 then - index = 1 - else - index = 2 - end - else - if startPos.z > 0 then - index = 3 - else - index = 4 - end - end - -- update the color of the hand zone - local handZone = getObjectFromGUID(HAND_ZONE_GUIDS[index]) + local handZone = getObjectFromMemo(MATCOLOR, "HandZone") handZone.setValue(color) -- if the seated player clicked this, reseat him to the new color @@ -880,8 +888,8 @@ 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 = getObjectFromGUID(CLUE_COUNTER_GUID) - local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) + local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter") + local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter") local clickerPos = CLUE_CLICKER.getPosition() local clueCount = 0 @@ -917,8 +925,8 @@ end -- removes all clues (moving tokens to the trash and setting counters to 0) function removeClues() - local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) - local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) + local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter") + local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter") CLUE_COUNTER.call("removeAllClues") CLUE_CLICKER.call("updateVal", 0) @@ -930,10 +938,10 @@ function getClueCount(useClickableCounters) local count = 0 if useClickableCounters then - local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) + local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter") count = tonumber(CLUE_CLICKER.getVar("val")) else - local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) + local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter") count = tonumber(CLUE_COUNTER.getVar("exposedValue")) end return count @@ -995,11 +1003,3 @@ function updatePlayerCards(args) local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA") tokenManager.addPlayerCardData(playerCardData) end - --- utility function for rounding ----@param num Number Initial value ----@param numDecimalPlaces Number Amount of decimal places -function round(num, numDecimalPlaces) - local mult = 10^(numDecimalPlaces or 0) - return math.floor(num * mult + 0.5) / mult -end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 9df18be2..2f20b299 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -2,26 +2,26 @@ do local PlaymatApi = { } local internal = { } - local MAT_IDS = { - White = "8b081b", - Orange = "bd0ff4", - Green = "383d8b", - Red = "0840d5" - } + -- 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 - local CLUE_COUNTER_GUIDS = { - White = "37be78", - Orange = "1769ed", - Green = "032300", - Red = "d86b7c" - } + 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 - local CLUE_CLICKER_GUIDS = { - White = "db85d6", - Orange = "3f22e5", - Green = "891403", - Red = "4111de" - } + 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 @@ -44,7 +44,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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") return mat.getVar("playerColor") end @@ -62,21 +62,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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end @@ -84,7 +84,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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") return mat.call("returnGlobalDiscardPosition") end @@ -92,14 +92,14 @@ do ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playermat PlaymatApi.transformLocalPosition = function(localPos, matColor) - local mat = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") return mat.getRotation() end @@ -107,14 +107,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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "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 = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") return mat.getVar("activeInvestigatorId") end @@ -180,7 +180,7 @@ do -- Returns the resource counter amount for the requested playermat PlaymatApi.getResourceCount = function(matColor) - local mat = getObjectFromGUID(MAT_IDS[matColor]) + local mat = internal.getObjectFromMemo(matColor, "Playermat") return mat.call("getResourceCount") end @@ -197,8 +197,8 @@ do end end - PlaymatApi.updateClueClicker = function(playerColor, val) - return getObjectFromGUID(CLUE_CLICKER_GUIDS[playerColor]).call("updateVal", val) + PlaymatApi.updateClueClicker = function(matColor, val) + return internal.getObjectFromMemo(matColor, "ClickableClueCounter").call("updateVal", val) end -- Convenience function to look up a mat's object by color, or get all mats. @@ -207,16 +207,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 targetMatGuid = MAT_IDS[matColor] - if targetMatGuid != nil then - return { getObjectFromGUID(targetMatGuid) } + local targetMat = internal.getObjectFromMemo(matColor, "Playermat") + if targetMat != nil then + return { targetMatGuid } end if matColor == "All" then return { - getObjectFromGUID(MAT_IDS.White), - getObjectFromGUID(MAT_IDS.Orange), - getObjectFromGUID(MAT_IDS.Green), - getObjectFromGUID(MAT_IDS.Red), + internal.getObjectFromMemo("White", "Playermat"), + internal.getObjectFromMemo("Orange", "Playermat"), + internal.getObjectFromMemo("Green", "Playermat"), + internal.getObjectFromMemo("Red", "Playermat"), } end end From c11ef5dabab1be37aa3a0e5f81a03ae0dfe104cc Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 13:41:43 +0200 Subject: [PATCH 05/76] more dynamic references --- config.json | 2 +- modsettings/ComponentTags.json | 4 -- objects/AllPlayerCards.15bb07.json | 1 + objects/ArkhamDBDeckImporter.a28140.json | 1 + objects/InvestigatorCount.f182ee.json | 1 + objects/NavigationOverlayHandler.797ede.json | 1 + objects/Playarea.721ba2.json | 2 +- objects/SoundCube.3c988f.json | 4 +- src/accessories/TokenArrangerApi.ttslua | 23 +------- src/arkhamdb/DeckImporterApi.ttslua | 9 ++-- src/chaosbag/BlessCurseManagerApi.ttslua | 38 ++++--------- src/core/Global.ttslua | 57 +++++++++++++++++++- src/core/NavigationOverlayApi.ttslua | 9 ++-- src/core/PlayAreaApi.ttslua | 38 +++++++------ src/core/SoundCubeApi.ttslua | 3 +- src/core/VictoryDisplay.ttslua | 3 +- src/core/VictoryDisplayApi.ttslua | 7 +-- src/playercards/AllCardsBagApi.ttslua | 54 ++++++++++--------- src/playermat/ClueCounter.ttslua | 7 ++- src/playermat/Playmat.ttslua | 40 +++----------- src/playermat/PlaymatApi.ttslua | 53 ++++++------------ 21 files changed, 168 insertions(+), 189 deletions(-) diff --git a/config.json b/config.json index f697884f..790e3a11 100644 --- a/config.json +++ b/config.json @@ -101,7 +101,7 @@ "ClueCounter.d86b7c", "MasterClueCounter.4a3aa4", "LegacyAssets.7165a9", - "Playarea.721ba2", + "PlayArea.721ba2", "BarkhamHorror.308439", "ScriptingTrigger.fb28e1", "ScriptingTrigger.7af2cf", diff --git a/modsettings/ComponentTags.json b/modsettings/ComponentTags.json index 83a638b1..ad3908c8 100644 --- a/modsettings/ComponentTags.json +++ b/modsettings/ComponentTags.json @@ -72,10 +72,6 @@ "displayed": "LargeBox", "normalized": "largebox" }, - { - "displayed": "SoundCube", - "normalized": "soundcube" - }, { "displayed": "CampaignBox", "normalized": "campaignbox" diff --git a/objects/AllPlayerCards.15bb07.json b/objects/AllPlayerCards.15bb07.json index f0715db7..af75a7b5 100644 --- a/objects/AllPlayerCards.15bb07.json +++ b/objects/AllPlayerCards.15bb07.json @@ -1575,6 +1575,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"AllCardsBag\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "All Player Cards", diff --git a/objects/ArkhamDBDeckImporter.a28140.json b/objects/ArkhamDBDeckImporter.a28140.json index 418d63a3..8a42ae1a 100644 --- a/objects/ArkhamDBDeckImporter.a28140.json +++ b/objects/ArkhamDBDeckImporter.a28140.json @@ -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, diff --git a/objects/InvestigatorCount.f182ee.json b/objects/InvestigatorCount.f182ee.json index 3229f06b..8566a1aa 100644 --- a/objects/InvestigatorCount.f182ee.json +++ b/objects/InvestigatorCount.f182ee.json @@ -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, diff --git a/objects/NavigationOverlayHandler.797ede.json b/objects/NavigationOverlayHandler.797ede.json index 7b15773a..16a9c51f 100644 --- a/objects/NavigationOverlayHandler.797ede.json +++ b/objects/NavigationOverlayHandler.797ede.json @@ -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, diff --git a/objects/Playarea.721ba2.json b/objects/Playarea.721ba2.json index 74caeab4..8057603a 100644 --- a/objects/Playarea.721ba2.json +++ b/objects/Playarea.721ba2.json @@ -975,7 +975,7 @@ "MeasureMovement": false, "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayArea\"}", "Name": "Custom_Token", - "Nickname": "Playarea", + "Nickname": "Play Area", "Snap": true, "Sticky": true, "Tags": [ diff --git a/objects/SoundCube.3c988f.json b/objects/SoundCube.3c988f.json index c27821d2..fb205aeb 100644 --- a/objects/SoundCube.3c988f.json +++ b/objects/SoundCube.3c988f.json @@ -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, diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 4538431d..aa02d0ce 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -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 diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 3250bf97..8bab141a 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -1,7 +1,6 @@ do local DeckImporterApi = {} - local DECK_IMPORTER_GUID = "a28140" - + -- Returns a table with the full state of the UI, including options and deck IDs. -- This can be used to persist via onSave(), or provide values for a load operation -- Table values: @@ -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 diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index 87dfb60b..d6c8a9f0 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -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 diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 96c45de3..52b97149 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -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) - spawnTable.data["Memo"] = "{\"matColor\":\"" .. color .. "\",\"type\":\"" .. name:gsub("%s+", "") .. "\"}" + 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 diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index 2a462807..865da421 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -1,21 +1,22 @@ 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 }) - end + end -- 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 diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index ad6a5b7a..829b6f6f 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -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 diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index de97f117..18a18bf5 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -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 diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index bf8a5502..0d642ce2 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -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 = {} diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index 2401ba43..4ba047f1 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -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 diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index c9223331..76216d81 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -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 - -- returned. Otherwise, a single table with the following fields - -- cardData: TTS object data, suitable for spawning the card - -- cardMetadata: Table of parsed metadata + ---@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 diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 3dcaa490..9ea4069c 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -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 diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index a36c554a..0b207050 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -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 diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 2f20b299..432a4dde 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -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 From 84590343a26ec7c90be6d5bcc2bacd6f5dafc3c6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 14:09:54 +0200 Subject: [PATCH 06/76] even more dynamic references --- objects/DataHelper.708279.json | 1 + objects/OptionPanelSource.830bd0.json | 1 + objects/ScriptingTrigger.a2f932.json | 1 + objects/TokenSource.124381.json | 1 + src/accessories/CleanUpHelper.ttslua | 18 ++++++++------- src/core/Global.ttslua | 32 ++++++++++++--------------- src/core/MythosArea.ttslua | 11 ++++----- src/core/MythosAreaApi.ttslua | 9 ++++---- src/core/PlayArea.ttslua | 4 +--- src/core/token/TokenManager.ttslua | 9 ++------ 10 files changed, 40 insertions(+), 47 deletions(-) diff --git a/objects/DataHelper.708279.json b/objects/DataHelper.708279.json index 1e3696b0..78a32f2e 100644 --- a/objects/DataHelper.708279.json +++ b/objects/DataHelper.708279.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/DataHelper\")", "LuaScriptState": "[]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DataHelper\"}", "Name": "Custom_Tile", "Nickname": "Data Helper", "Snap": true, diff --git a/objects/OptionPanelSource.830bd0.json b/objects/OptionPanelSource.830bd0.json index 98907beb..9b7d96ce 100644 --- a/objects/OptionPanelSource.830bd0.json +++ b/objects/OptionPanelSource.830bd0.json @@ -38,6 +38,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"OptionPanelSource\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "OptionPanel Source", diff --git a/objects/ScriptingTrigger.a2f932.json b/objects/ScriptingTrigger.a2f932.json index faded6f2..bf81ab5a 100644 --- a/objects/ScriptingTrigger.a2f932.json +++ b/objects/ScriptingTrigger.a2f932.json @@ -25,6 +25,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayAreaZone\"}", "Name": "ScriptingTrigger", "Nickname": "", "Snap": true, diff --git a/objects/TokenSource.124381.json b/objects/TokenSource.124381.json index 7b6b34fb..138ba64d 100644 --- a/objects/TokenSource.124381.json +++ b/objects/TokenSource.124381.json @@ -37,6 +37,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenSource\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "Token Source", diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 3d25e52c..7110fb7f 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -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 }, diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 52b97149..97c567dd 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -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 diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 46b4fda7..3391e54f 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -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 diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 4eeeb693..c7b406d9 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -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 diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 69cbba2c..0dee301c 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -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 diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 3687ee64..95386196 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -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 From 3292f2a2d1b86cc7d45c00ea4a13b2fa3f33306c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 15:09:57 +0200 Subject: [PATCH 07/76] bundle object references into a table --- src/core/Global.ttslua | 6 ++-- src/playermat/Playmat.ttslua | 59 +++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 97c567dd..00c974ca 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -181,6 +181,7 @@ end -- gets all objects that match the provided matcolor ---@param matColor String Color of the playermat +---@return objList Table Table of type-object pairs function getObjectsForMatColor(matColor) local objList = {} if matColor == nil then return objList end @@ -189,7 +190,7 @@ function getObjectsForMatColor(matColor) if memo then local decoded = JSON.decode(memo) or {} if decoded.matColor == matColor then - table.insert(objList, obj) + objList[decoded.type] = obj end end end @@ -198,6 +199,7 @@ end -- gets all objects that match the provided type, sorted by owner ---@param type String Object to look for (usually name without spaces) +---@return objList Table Table of matColor-object pairs function getObjectsForType(type) local objList = {} if type == nil then return objList end @@ -206,7 +208,7 @@ function getObjectsForType(type) if memo then local decoded = JSON.decode(memo) or {} if decoded.type == type then - table.insert(objList, obj) + objList[decoded.matColor] = obj end end end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 0b207050..a2328639 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -61,7 +61,10 @@ 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, CLUE_COUNTER, CLUE_CLICKER +-- table of type-object reference pairs of all owned objects +local ownedObjects = {} + +-- variable to track the status of the "Show Draw Button" option local isDrawButtonVisible = false -- global variable to report "Dream-Enhancing Serum" status @@ -79,14 +82,9 @@ end function onLoad(save_state) self.interactable = DEBUG - -- set MATCOLOR based on memo - MATCOLOR = JSON.decode(self.getMemo()).matColor - - 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"}) + -- get object references to owned objects + local matColor= JSON.decode(self.getMemo()).matColor + ownedObjects = Global.call("getObjectsForMatColor", matColor) -- button creation for i = 1, 6 do @@ -244,7 +242,7 @@ function makeDiscardHandlerFor(searchPosition, ) chaosBag.putObject(obj) -- don't touch the table or this playmat itself elseif obj.guid ~= "4ee1f2" and obj ~= self then - TRASHCAN.putObject(obj) + ownedObjects.Trash.putObject(obj) end end end @@ -425,14 +423,14 @@ end -- adds the specified amount of resources to the resource counter function gainResources(amount) - local count = RESOURCE_COUNTER.getVar("val") + local count = ownedObjects.ResourceCounter.getVar("val") local add = tonumber(amount) or 0 - RESOURCE_COUNTER.call("updateVal", count + add) + ownedObjects.ResourceCounter.call("updateVal", count + add) end -- returns the resource counter amount function getResourceCount() - return RESOURCE_COUNTER.getVar("val") + return ownedObjects.ResourceCounter.getVar("val") end -- function for "draw 1 button" (that can be added via option panel) @@ -584,7 +582,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 = Global.call("getObjectFromMemo", {matColor = MATCOLOR, "HandZone"}) + local handZone = ownedObjects.HandZone handZone.setValue(color) -- if the seated player clicked this, reseat him to the new color @@ -748,7 +746,7 @@ function removeTokensFromObject(object) obj.getLock() == false and obj.getDescription() ~= "Action Token" and not tokenChecker.isChaosToken(obj) then - TRASHCAN.putObject(obj) + ownedObjects.TrashCan.putObject(obj) end end end @@ -767,11 +765,16 @@ function maybeUpdateActiveInvestigator(card) if notes.id == activeInvestigatorId then return end class = notes.class activeInvestigatorId = notes.id - STAT_TRACKER.call("updateStats", {notes.willpowerIcons, notes.intellectIcons, notes.combatIcons, notes.agilityIcons}) + ownedObjects.InvestigatorSkillTracker.call("updateStats", { + notes.willpowerIcons, + notes.intellectIcons, + notes.combatIcons, + notes.agilityIcons + }) elseif activeInvestigatorId ~= "00000" then class = "Neutral" activeInvestigatorId = "00000" - STAT_TRACKER.call("updateStats", {1, 1, 1, 1}) + ownedObjects.InvestigatorSkillTracker.call("updateStats", {1, 1, 1, 1}) else return end @@ -869,29 +872,29 @@ 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 clickerPos = CLUE_CLICKER.getPosition() + local clickerPos = ownedObjects.ClickableClueCounter.getPosition() local clueCount = 0 if showCounter then -- current clue count - clueCount = CLUE_COUNTER.getVar("exposedValue") + clueCount = ownedObjects.ClueCounter.getVar("exposedValue") -- remove clues - CLUE_COUNTER.call("removeAllClues") + ownedObjects.ClueCounter.call("removeAllClues") -- set value for clue clickers - CLUE_CLICKER.call("updateVal", clueCount) + ownedObjects.ClickableClueCounter.call("updateVal", clueCount) -- move clue counters up clickerPos.y = 1.52 - CLUE_CLICKER.setPosition(clickerPos) + ownedObjects.ClickableClueCounter.setPosition(clickerPos) else -- current clue count - clueCount = CLUE_CLICKER.getVar("val") + clueCount = ownedObjects.ClickableClueCounter.getVar("val") -- move clue counters down clickerPos.y = 1.3 - CLUE_CLICKER.setPosition(clickerPos) + ownedObjects.ClickableClueCounter.setPosition(clickerPos) -- spawn clues local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7}) @@ -904,8 +907,8 @@ end -- removes all clues (moving tokens to the trash and setting counters to 0) function removeClues() - CLUE_COUNTER.call("removeAllClues") - CLUE_CLICKER.call("updateVal", 0) + ownedObjects.ClueCounter.call("removeAllClues") + ownedObjects.ClickableClueCounter.call("updateVal", 0) end -- reports the clue count @@ -914,9 +917,9 @@ function getClueCount(useClickableCounters) local count = 0 if useClickableCounters then - count = tonumber(CLUE_CLICKER.getVar("val")) + count = tonumber(ownedObjects.ClickableClueCounter.getVar("val")) else - count = tonumber(CLUE_COUNTER.getVar("exposedValue")) + count = tonumber(ownedObjects.ClueCounter.getVar("exposedValue")) end return count end From 4c0c02531989b2a9fdc0d2b09568bd5882f60321 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 17:00:31 +0200 Subject: [PATCH 08/76] clean up helper update to dynamic references --- objects/Blesstokens.afa06b.json | 1 + objects/Cluetokens.11e0cf.json | 3 + objects/Connectionmarkers.170f10.json | 3 + objects/Cursetokens.bd0253.json | 1 + objects/DoomCounter.85c4c6.json | 4 + objects/Doomtokens.47ffc3.json | 3 + objects/Doomtokens.b015d8.json | 3 + objects/MasterClueCounter.4a3aa4.json | 5 +- objects/MythosArea.9f334f.json | 3 + src/accessories/CleanUpHelper.ttslua | 149 +++++------------- .../cards/FamilyInheritance.ttslua | 6 +- src/playercards/cards/WellConnected.ttslua | 81 +++++----- src/playermat/Playmat.ttslua | 52 ++++-- src/playermat/PlaymatApi.ttslua | 43 +++-- 14 files changed, 176 insertions(+), 181 deletions(-) diff --git a/objects/Blesstokens.afa06b.json b/objects/Blesstokens.afa06b.json index c6945406..002460c9 100644 --- a/objects/Blesstokens.afa06b.json +++ b/objects/Blesstokens.afa06b.json @@ -67,6 +67,7 @@ "Snap": true, "Sticky": true, "Tags": [ + "CleanUpHelper_ignore", "displacement_excluded" ], "Tooltip": true, diff --git a/objects/Cluetokens.11e0cf.json b/objects/Cluetokens.11e0cf.json index 81c5e92d..24b017b6 100644 --- a/objects/Cluetokens.11e0cf.json +++ b/objects/Cluetokens.11e0cf.json @@ -44,6 +44,9 @@ "Nickname": "Clue tokens", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": 2.857, diff --git a/objects/Connectionmarkers.170f10.json b/objects/Connectionmarkers.170f10.json index 26848bae..0df49af2 100644 --- a/objects/Connectionmarkers.170f10.json +++ b/objects/Connectionmarkers.170f10.json @@ -44,6 +44,9 @@ "Nickname": "Connection markers", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": -51, diff --git a/objects/Cursetokens.bd0253.json b/objects/Cursetokens.bd0253.json index 41b510ac..8a9e2f98 100644 --- a/objects/Cursetokens.bd0253.json +++ b/objects/Cursetokens.bd0253.json @@ -67,6 +67,7 @@ "Snap": true, "Sticky": true, "Tags": [ + "CleanUpHelper_ignore", "displacement_excluded" ], "Tooltip": true, diff --git a/objects/DoomCounter.85c4c6.json b/objects/DoomCounter.85c4c6.json index d93d5341..c5d41256 100644 --- a/objects/DoomCounter.85c4c6.json +++ b/objects/DoomCounter.85c4c6.json @@ -36,10 +36,14 @@ "LuaScript": "require(\"core/DoomCounter\")", "LuaScriptState": "[0,{\"Agenda\":true,\"Playarea\":true,\"Playermats\":true}]", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DoomCounter\"}", "Name": "Custom_Token", "Nickname": "Doom Counter", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": -5.3, diff --git a/objects/Doomtokens.47ffc3.json b/objects/Doomtokens.47ffc3.json index 51c4fbc0..059108ea 100644 --- a/objects/Doomtokens.47ffc3.json +++ b/objects/Doomtokens.47ffc3.json @@ -44,6 +44,9 @@ "Nickname": "Doom tokens", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": -55.48, diff --git a/objects/Doomtokens.b015d8.json b/objects/Doomtokens.b015d8.json index c4d4cd08..0c614022 100644 --- a/objects/Doomtokens.b015d8.json +++ b/objects/Doomtokens.b015d8.json @@ -44,6 +44,9 @@ "Nickname": "Doom tokens", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": 2.761, diff --git a/objects/MasterClueCounter.4a3aa4.json b/objects/MasterClueCounter.4a3aa4.json index c6b21615..69d25c0f 100644 --- a/objects/MasterClueCounter.4a3aa4.json +++ b/objects/MasterClueCounter.4a3aa4.json @@ -37,9 +37,12 @@ "LuaScriptState": "false", "MeasureMovement": false, "Name": "Custom_Token", - "Nickname": "Master Clue Counter\n", + "Nickname": "Master Clue Counter", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": true, "Transform": { "posX": -5.3, diff --git a/objects/MythosArea.9f334f.json b/objects/MythosArea.9f334f.json index 734c5d92..24b7fa4b 100644 --- a/objects/MythosArea.9f334f.json +++ b/objects/MythosArea.9f334f.json @@ -67,6 +67,9 @@ "Nickname": "Mythos Area", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": false, "Transform": { "posX": -1.309, diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 7110fb7f..324383f8 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -10,43 +10,15 @@ local playmatApi = require("playermat/PlaymatApi") local soundCubeApi = require("core/SoundCubeApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") --- these objects will be ignored -local IGNORE_GUIDS = { - -- big playmat, change image panel and investigator counter - "b7b45b", "f182ee", "721ba2", - -- bless/curse manager - "afa06b", "bd0253", "5933fb", - -- stuff on mythos area - "85c4c6", "4a3aa4", "fea079", "b015d8", "11e0cf", "9f334f", "70b9f6", "0a5a29", - -- doom/location token bag - "47ffc3", "170f10", - -- table - "4ee1f2" -} - -- objects with this tag will be ignored local IGNORE_TAG = "CleanUpHelper_ignore" -- colors and order for following tables local COLORS = { "White", "Orange", "Green", "Red", "Mythos" } --- counter GUIDS (4x damage and 4x horror) -local DAMAGE_HORROR_GUIDS = { - "eb08d6", "e64eec", "1f5a0a", "591a45", - "468e88", "0257d9", "7b5729", "beb964", -} - local campaignLog local RESET_VALUES = {} --- GUIDS of objects (in order of ownership relating to 'COLORS') -local PLAYERMAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } -local RESOURCE_GUIDS = { "4406f0", "816d84", "cd15ac", "a4b60d" } -local TRACKER_GUIDS = { "e598c2", "b4a5f7", "af7ed7", "e74881" } -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 mythos area, 6th for campaign log) local PHYSICS_POSITION = { { -54.5, 2, 21 }, @@ -131,14 +103,6 @@ function onLoad(savedData) buttonParameters.position.z = 1.1 buttonParameters.width = 1550 self.createButton(buttonParameters) - - -- create single table for ignoring - for _, v in ipairs(CLUE_GUIDS) do table.insert(IGNORE_GUIDS, v) end - for _, v in ipairs(CLUE_CLICKER_GUIDS) do table.insert(IGNORE_GUIDS, v) end - for _, v in ipairs(RESOURCE_GUIDS) do table.insert(IGNORE_GUIDS, v) end - for _, v in ipairs(TRASHCAN_GUIDS) do table.insert(IGNORE_GUIDS, v) end - for _, v in ipairs(PLAYERMAT_GUIDS) do table.insert(IGNORE_GUIDS, v) end - for _, v in ipairs(DAMAGE_HORROR_GUIDS) do table.insert(IGNORE_GUIDS, v) end end --------------------------------------------------------- @@ -178,13 +142,8 @@ function cleanUp(_, color) getTrauma() -- delay to account for potential state change - Wait.time(function() - updateCounters(RESOURCE_GUIDS, 5, "Resource") - updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clicker") - updateCounters(DAMAGE_HORROR_GUIDS, RESET_VALUES, "Damage / Horror") - end, 0.2) + Wait.time(updateCounters, 0.2) - resetSkillTrackers() resetDoomCounter() blessCurseManagerApi.removeAll(color) removeLines() @@ -200,39 +159,20 @@ end -- modular functions, called by other functions --------------------------------------------------------- -function updateCounters(tableOfGUIDs, newValues, info) - -- instead of a table, this will be used if just a single value is provided - local singleValue = tonumber(newValues) +function updateCounters() + playmatApi.updateCounter("All", "ResourceCounter" , 5) + playmatApi.updateCounter("All", "ClickableClueCounter" , 0) + playmatApi.resetSkillTracker("All") - for i, guid in ipairs(tableOfGUIDs) do - local TOKEN = getObjectFromGUID(guid) - local newValue = singleValue or newValues[i] - - if TOKEN ~= nil then - TOKEN.call("updateVal", newValue) - else - printToAll(info .. ": No. " .. i .. " could not be found.", "Yellow") - end - end -end - --- set investigator skill trackers to "1, 1, 1, 1" -function resetSkillTrackers() - for i, guid in ipairs(TRACKER_GUIDS) do - local obj = getObjectFromGUID(guid) - - if obj ~= nil then - obj.call("updateStats", { 1, 1, 1, 1 }) - else - printToAll("Skill tracker for " .. COLORS[i] .. " playmat could not be found.", "Yellow") - end + for i = 1, 4 do + playmatApi.updateCounter(COLORS[i], "DamageCounter", RESET_VALUES.Damage[i]) + playmatApi.updateCounter(COLORS[i], "HorrorCounter", RESET_VALUES.Horror[i]) end end -- reset doom on agenda function resetDoomCounter() - local doomCounter = getObjectFromGUID("85c4c6") - + local doomCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomCounter"}) if doomCounter ~= nil then doomCounter.call("updateVal") else @@ -240,19 +180,19 @@ function resetDoomCounter() end end --- gets the GUID of a custom data helper (if present) and adds it to the ignore list +-- adds the ignore tag to the custom data helper function ignoreCustomDataHelper() local customDataHelper = playAreaApi.getCustomDataHelper() if customDataHelper then - table.insert(IGNORE_GUIDS, customDataHelper.getGUID()) + customDataHelper.addTag(IGNORE_TAG) end end -- read values for trauma from campaign log if enabled function getTrauma() RESET_VALUES = { - 0, 0, 0, 0, - 0, 0, 0, 0 + Damage = { 0, 0, 0, 0 }, + Horror = { 0, 0, 0, 0 } } -- stop here if trauma import is disabled @@ -279,7 +219,14 @@ function loadTrauma() if trauma ~= nil then printToAll("Trauma values found in campaign log!", "Green") - RESET_VALUES = campaignLog.call("returnTrauma") + trauma = campaignLog.call("returnTrauma") + for i = 1, 8 do + if i < 5 then + RESET_VALUES.Damage[i] = trauma[i] + else + RESET_VALUES.Horror[i-4] = trauma[i] + end + end loadingFailedBefore = false elseif loadingFailedBefore then printToAll("Trauma values could not be found in campaign log!", "Yellow") @@ -302,7 +249,7 @@ end -- remove drawn lines function removeLines() if options["removeDrawnLines"] then - printToAll("Removing vector lines...", "White") + printToAll("Removing global vector lines...", "White") Global.setVectorLines({}) end end @@ -311,30 +258,30 @@ end function discardHands() if not options["tidyPlayermats"] then return end for i = 1, 4 do - local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[i]) - if trashcan == nil then return end + local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"}) + if trash == nil then return end local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects() for j = #hand, 1, -1 do - trashcan.putObject(hand[j]) + trash.putObject(hand[j]) end end end -- clean up for play area function tidyPlayareaCoroutine() - local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[5]) - local PLAYMATZONE = getObjectFromGUID("a2f932") + local trash = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) + local playAreaZone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"}) - if PLAYMATZONE == nil then + if playAreaZone == nil then printToAll("Scripting zone for main play area could not be found!", "Red") - elseif trashcan == nil then + elseif trash == nil then printToAll("Trashcan for main play area could not be found!", "Red") else - for _, obj in ipairs(PLAYMATZONE.getObjects()) do + for _, obj in ipairs(playAreaZone.getObjects()) do -- ignore these elements - if not tableContains(IGNORE_GUIDS, obj.getGUID()) and obj.hasTag(IGNORE_TAG) == false then + if obj.hasTag(IGNORE_TAG) == false then coroutine.yield(0) - trashcan.putObject(obj) + trash.putObject(obj) end end end @@ -352,34 +299,32 @@ function tidyPlayerMatCoroutine() -- delay for animation purpose for k = 1, 30 do coroutine.yield(0) end - -- get respective trashcan - local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[i]) - if trashcan == nil then + -- get respective trash + local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"}) + if trash == nil then printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red") return 1 end for _, entry in ipairs(findObjects(i)) do local obj = entry.hit_object - 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 obj.hasTag(IGNORE_TAG) == false + and obj.hasTag("ActionToken") == false + and obj.hasTag("chaosBag") == false then coroutine.yield(0) - trashcan.putObject(obj) + trash.putObject(obj) -- flip action tokens back to ready - elseif desc_low == "action token" and obj.is_face_down then + elseif obj.hasTag("ActionToken") == false and obj.is_face_down then obj.flip() end end -- reset "activeInvestigatorId" if i < 5 then - local playermat = getObjectFromGUID(PLAYERMAT_GUIDS[i]) + local playermat = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Playermat"}) if playermat then playermat.setVar("activeInvestigatorId", "00000") end @@ -387,7 +332,7 @@ function tidyPlayerMatCoroutine() end end - local datahelper = getObjectFromGUID("708279") + local datahelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"}) if datahelper then datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {}) end @@ -412,13 +357,3 @@ function findObjects(num) debug = false }) end - --- search a table for a value, return true if found (else returns false) -function tableContains(table, value) - for _, v in ipairs(table) do - if v == value then - return true - end - end - return false -end diff --git a/src/playercards/cards/FamilyInheritance.ttslua b/src/playercards/cards/FamilyInheritance.ttslua index 0bbab561..b33b177c 100644 --- a/src/playercards/cards/FamilyInheritance.ttslua +++ b/src/playercards/cards/FamilyInheritance.ttslua @@ -16,8 +16,8 @@ function searchSelf() for _, obj in ipairs(searchArea(self.getPosition(), { 2.5, 0.5, 3.5 })) do local obj = obj.hit_object - if obj.getCustomObject().image == - "http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/" then + local image = obj.getCustomObject().image + if image == "http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/" then foundTokens = foundTokens + math.abs(obj.getQuantity()) obj.destruct() elseif obj.getMemo() == "resourceCounter" then @@ -47,7 +47,7 @@ end function takeAll(playerColor) searchSelf() local matColor = playmatApi.getMatColorByPosition(self.getPosition()) - playmatApi.gainResources(foundTokens, matColor) + playmatApi.updateCounter(matColor, "ResourceCounter", foundTokens) if clickableResourceCounter then clickableResourceCounter.call("updateVal", 0) diff --git a/src/playercards/cards/WellConnected.ttslua b/src/playercards/cards/WellConnected.ttslua index 7e7fda73..872a7c5a 100644 --- a/src/playercards/cards/WellConnected.ttslua +++ b/src/playercards/cards/WellConnected.ttslua @@ -7,66 +7,65 @@ local modValue = 5 -- level 0 Well Connected local loopId = nil local b_display = { - click_function = "toggleCounter", - function_owner = self, - position = {0.88,0.5,-1.33}, - font_size = 150, - width = 175, - height = 175 + click_function = "toggleCounter", + function_owner = self, + position = { 0.88, 0.5, -1.33 }, + font_size = 150, + width = 175, + height = 175 } function onLoad(saved_data) - local notes = JSON.decode(self.getGMNotes()) + local notes = JSON.decode(self.getGMNotes()) - if notes.id == "54006" then -- hardcoded card id for upgraded Well Connected (3) - modValue = 4 -- Well Connected (3) - end + if notes.id == "54006" then -- hardcoded card id for upgraded Well Connected (3) + modValue = 4 -- Well Connected (3) + end - if saved_data != '' then - local loaded_data = JSON.decode(saved_data) - display = not loaded_data.saved_display + if saved_data != '' then + local loaded_data = JSON.decode(saved_data) + display = not loaded_data.saved_display - self.clearButtons() - toggleCounter() - end - - self.addContextMenuItem('Toggle Counter', toggleCounter) + self.clearButtons() + toggleCounter() + end + + self.addContextMenuItem('Toggle Counter', toggleCounter) end function onSave() - return JSON.encode({saved_display = display}) + return JSON.encode({ saved_display = display }) end function toggleCounter() - display = not display + display = not display - if display then - createUpdateDisplay() - loopId = Wait.time(|| createUpdateDisplay(), 2, -1) - else - if loopId ~= nil then - Wait.stop(loopId) - end - - self.clearButtons() - loopId = nil + if display then + createUpdateDisplay() + loopId = Wait.time(createUpdateDisplay, 2, -1) + else + if loopId ~= nil then + Wait.stop(loopId) end + + self.clearButtons() + loopId = nil + end end function createUpdateDisplay() - count = math.max(math.floor(getPlayerResources() / modValue), 0) + count = math.max(math.floor(getPlayerResources() / modValue), 0) - b_display.label = tostring(count) + b_display.label = tostring(count) - if loopId == nil then - self.createButton(b_display) - else - self.editButton(b_display) - end + if loopId == nil then + self.createButton(b_display) + else + self.editButton(b_display) + end end function getPlayerResources() - local matColor = playmatApi.getMatColorByPosition(self.getPosition()) - - return playmatApi.getResourceCount(matColor) -end \ No newline at end of file + local matColor = playmatApi.getMatColorByPosition(self.getPosition()) + return playmatApi.getCounterValue(matColor, "ResourceCounter") +end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index a2328639..959970a7 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -63,6 +63,7 @@ activeInvestigatorId = "00000" -- table of type-object reference pairs of all owned objects local ownedObjects = {} +local matColor = JSON.decode(self.getMemo()).matColor -- variable to track the status of the "Show Draw Button" option local isDrawButtonVisible = false @@ -83,7 +84,6 @@ function onLoad(save_state) self.interactable = DEBUG -- get object references to owned objects - local matColor= JSON.decode(self.getMemo()).matColor ownedObjects = Global.call("getObjectsForMatColor", matColor) -- button creation @@ -392,10 +392,10 @@ function doUpkeep(_, clickedByColor, isRightClick) -- gain a resource (or two if playing Jenny Barnes) if string.match(activeInvestigatorId, "%d%d%d%d%d") == "02003" then - gainResources(2) + updateCounter({type = "ResourceCounter", modifier = 2}) printToColor("Gaining 2 resources (Jenny)", messageColor) else - gainResources(1) + updateCounter({type = "ResourceCounter", modifier = 1}) end -- draw a card (with handling for Patrice and Forced Learning) @@ -421,18 +421,6 @@ function doUpkeep(_, clickedByColor, isRightClick) end end --- adds the specified amount of resources to the resource counter -function gainResources(amount) - local count = ownedObjects.ResourceCounter.getVar("val") - local add = tonumber(amount) or 0 - ownedObjects.ResourceCounter.call("updateVal", count + add) -end - --- returns the resource counter amount -function getResourceCount() - return ownedObjects.ResourceCounter.getVar("val") -end - -- function for "draw 1 button" (that can be added via option panel) function doDrawOne(_, color) -- send messages to player who clicked button if no seated player found @@ -822,6 +810,40 @@ function setObjectState(obj, stateId) if obj.getStateId() ~= stateId then obj.setState(stateId) end end +--------------------------------------------------------- +-- manipulation of owned objects +--------------------------------------------------------- + +-- updates the specific owned counter +---@param param Table Contains the information to update: +--- type: String Counter to target +--- newValue: Number Value to set the counter to +--- modifier: Number If newValue is not provided, the existing value will be adjusted by this modifier +function updateCounter(param) + local counter = ownedObjects[param.type] + if counter ~= nil then + counter.call("updateVal", param.newValue or (counter.getVar("val") + param.modifier)) + else + printToAll(param.type .. " for " .. matColor .. " could not be found.", "Yellow") + end +end + +-- returns the resource counter amount +---@param type String Counter to target +function getCounterValue(type) + return ownedObjects.type.getVar("val") +end + +-- set investigator skill tracker to "1, 1, 1, 1" +function resetSkillTracker() + local obj = ownedObjects.InvestigatorSkillTracker + if obj ~= nil then + obj.call("updateStats", { 1, 1, 1, 1 }) + else + printToAll("Skill tracker for " .. matColor .. " playmat could not be found.", "Yellow") + end +end + --------------------------------------------------------- -- calls to 'Global' / functions for calls from outside --------------------------------------------------------- diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 432a4dde..5aee71b1 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -150,17 +150,34 @@ do return count end - -- Adds the specified amount of resources to the requested playermat's resource counter - PlaymatApi.gainResources = function(amount, matColor) + -- updates the specified owned counter + ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also + -- accepts "All" as a special value which will return all four mats. + ---@param type String Counter to target + ---@param newValue Number Value to set the counter to + ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier + PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) for _, mat in ipairs(internal.getMatForColor(matColor)) do - mat.call("gainResources", amount) + mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier}) end end - -- Returns the resource counter amount for the requested playermat - PlaymatApi.getResourceCount = function(matColor) + -- returns the resource counter amount + ---@param matColor String Color of the playermat + ---@param type String Counter to target + PlaymatApi.getCounterValue = function(matColor, type) local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.call("getResourceCount") + return mat.call("getCounterValue", type) + end + + + -- resets the specified skill tracker to "1, 1, 1, 1" + ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also + -- accepts "All" as a special value which will return all four mats. + PlaymatApi.resetSkillTracker = function(matColor) + for _, mat in ipairs(internal.getMatForColor(matColor)) do + mat.call("resetSkillTracker") + end end -- Discard a non-hidden card from the corresponding player's hand @@ -186,17 +203,15 @@ 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 = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - if targetMat != nil then - return { targetMatGuid } - end if matColor == "All" then return { - 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"}) + 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"}) } + else + return { Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) } end end From aafc14549585e24ec841d97362a4374d715acd35 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 17:06:55 +0200 Subject: [PATCH 09/76] additional memo check for CUH --- src/accessories/CleanUpHelper.ttslua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 324383f8..428cf377 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -279,7 +279,7 @@ function tidyPlayareaCoroutine() else for _, obj in ipairs(playAreaZone.getObjects()) do -- ignore these elements - if obj.hasTag(IGNORE_TAG) == false then + if obj.hasTag(IGNORE_TAG) == false and checkMemo(obj) == false then coroutine.yield(0) trash.putObject(obj) end @@ -312,7 +312,8 @@ function tidyPlayerMatCoroutine() -- ignore these elements if obj.hasTag(IGNORE_TAG) == false and obj.hasTag("ActionToken") == false - and obj.hasTag("chaosBag") == false then + and obj.hasTag("chaosBag") == false + and checkMemo(obj) == false then coroutine.yield(0) trash.putObject(obj) @@ -357,3 +358,15 @@ function findObjects(num) debug = false }) end + +-- checks if the object is owned by a playermat or the mythos, returns boolean +function checkMemo(obj) + local memo = obj.getMemo() + if memo then + local decoded = JSON.decode(memo) or {} + if decoded.matColor then + return true + end + end + return false +end From a87b63516a9eee4e71be1303dec487df371e8515 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 00:10:06 +0200 Subject: [PATCH 10/76] turned cleanuphelper and playmatapi dynamic --- src/accessories/CleanUpHelper.ttslua | 65 +++----- src/core/GameKeyHandler.ttslua | 2 +- src/core/NavigationOverlayHandler.ttslua | 2 +- src/playercards/cards/ShortSupply.ttslua | 8 +- src/playermat/Playmat.ttslua | 2 +- src/playermat/PlaymatApi.ttslua | 204 +++++++++++------------ 6 files changed, 129 insertions(+), 154 deletions(-) diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 428cf377..8523a6f7 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -15,39 +15,11 @@ local IGNORE_TAG = "CleanUpHelper_ignore" -- colors and order for following tables local COLORS = { "White", "Orange", "Green", "Red", "Mythos" } - local campaignLog local RESET_VALUES = {} - --- 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 }, - { -27.0, 2, 26 }, - { -27.0, 2, -26 }, - { -02.0, 2, 10 }, - { -00.0, 2, -27 } -} - -local PHYSICS_ROTATION = { - 270, - 270, - 0, - 180, - 270, - 0 -} - -local PHYSICS_SCALE = { - { 36.6, 1, 14.5 }, - { 36.6, 1, 14.5 }, - { 34.0, 1, 14.5 }, - { 34.0, 1, 14.5 }, - { 55.0, 1, 13.5 }, - { 05.0, 1, 05.0 } -} - +local loadingFailedBefore = false local optionsVisible = false + local options = {} options["importTrauma"] = true options["tidyPlayermats"] = true @@ -56,7 +28,6 @@ options["removeDrawnLines"] = false local buttonParameters = {} buttonParameters.function_owner = self -local loadingFailedBefore = false --------------------------------------------------------- -- option loading and GUI setup @@ -202,13 +173,12 @@ function getTrauma() end -- get campaign log - campaignLog = findObjects(6)[1] + campaignLog = getObjectsWithTag("CampaignLog")[1] if campaignLog == nil then printToAll("Campaign log not found in standard position!", "Yellow") printToAll("Default values for health and sanity loaded.", "Yellow") return end - campaignLog = campaignLog.hit_object loadTrauma() end @@ -306,9 +276,14 @@ function tidyPlayerMatCoroutine() return 1 end - for _, entry in ipairs(findObjects(i)) do - local obj = entry.hit_object + local objList + if i < 5 then + objList = playmatApi.searchAroundPlaymat(COLORS[i]) + else + objList = searchMythosArea() + end + for _, obj in ipairs(objList) do -- ignore these elements if obj.hasTag(IGNORE_TAG) == false and obj.hasTag("ActionToken") == false @@ -317,7 +292,7 @@ function tidyPlayerMatCoroutine() coroutine.yield(0) trash.putObject(obj) - -- flip action tokens back to ready + -- flip action tokens back to ready elseif obj.hasTag("ActionToken") == false and obj.is_face_down then obj.flip() end @@ -346,17 +321,23 @@ end -- helper functions --------------------------------------------------------- --- find objects depending on index (1 to 4 for playermats, 5 for mythos area, 6 for campaign log) -function findObjects(num) - return Physics.cast({ +-- find objects in the mythos area +function searchMythosArea() + local searchResult = Physics.cast({ direction = { 0, 1, 0 }, max_distance = 1, type = 3, - size = PHYSICS_SCALE[num], - origin = PHYSICS_POSITION[num], - orientation = { 0, PHYSICS_ROTATION[num], 0 }, + size = { 55, 1, 13.5 }, + origin = { -2, 2, 10 }, + orientation = { 0, 270, 0 }, debug = false }) + + local objList = {} + for _, v in ipairs(searchResult) do + table.insert(objList, v.hit_object) + end + return objList end -- checks if the object is owned by a playermat or the mythos, returns boolean diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 192defd7..2ee982c3 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -105,7 +105,7 @@ function takeClueFromLocation(playerColor, hoveredObject) local pos = nil if clickableClues then pos = {x = 0.49, y = 2.66, z = 0.00} - playmatApi.updateClueClicker(playerColor, playmatApi.getClueCount(clickableClues, playerColor) + 1) + playmatApi.updateCounter(matColor, "ClickableClueCounter", _, 1) else pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor) end diff --git a/src/core/NavigationOverlayHandler.ttslua b/src/core/NavigationOverlayHandler.ttslua index 9aea6188..77fdc345 100644 --- a/src/core/NavigationOverlayHandler.ttslua +++ b/src/core/NavigationOverlayHandler.ttslua @@ -328,7 +328,7 @@ function loadCamera(player, index) end -- search on the playmat for objects - local bounds = getDynamicViewBounds(playmatApi.searchPlaymat(matColor)) + local bounds = getDynamicViewBounds(playmatApi.searchAroundPlaymat(matColor)) lookHere = { position = { bounds.middleX, 0, bounds.middleZ }, diff --git a/src/playercards/cards/ShortSupply.ttslua b/src/playercards/cards/ShortSupply.ttslua index 71c5d9bf..f01e6204 100644 --- a/src/playercards/cards/ShortSupply.ttslua +++ b/src/playercards/cards/ShortSupply.ttslua @@ -1,4 +1,4 @@ -local playmatAPI = require("playermat/PlaymatApi") +local playmatApi = require("playermat/PlaymatApi") function onLoad() self.addContextMenuItem("Discard 10 cards", shortSupply) @@ -6,11 +6,11 @@ end -- called by context menu entry function shortSupply(color) - local matColor = playmatAPI.getMatColorByPosition(self.getPosition()) + local matColor = playmatApi.getMatColorByPosition(self.getPosition()) -- get draw deck and discard position - local drawDeck = playmatAPI.getDrawDeck(matColor) - local discardPos = playmatAPI.getDiscardPosition(matColor) + local drawDeck = playmatApi.getDrawDeck(matColor) + local discardPos = playmatApi.getDiscardPosition(matColor) -- error handling if discardPos == nil then diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index d92e0caf..449aab2e 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -183,7 +183,7 @@ function isCard(x) return x.type == 'Card' end function isDeck(x) return x.type == 'Deck' end function isCardOrDeck(x) return x.type == 'Card' or x.type == 'Deck' end --- Finds all objects on the playmat and associated set aside zone. +-- finds all objects on the playmat and associated set aside zone. function searchAroundSelf(filter) local bounds = self.getBoundsNormalized() -- Increase the width to cover the set aside zone diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 5aee71b1..f7677177 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -1,217 +1,211 @@ do - local PlaymatApi = { } - local internal = { } + local PlaymatApi = {} + local internal = {} - -- 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 + -- Returns the color of the closest playmat + ---@param startPos Table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) - if startPos.x < -42 then - if startPos.z > 0 then - return "White" - else - return "Orange" - end - else - if startPos.z > 0 then - return "Green" - else - return "Red" + local result, smallestDistance + for matColor, mat in pairs(internal.getMatForColor("All")) do + local distance = Vector.between(startPos, mat.getPosition()):magnitude() + if smallestDistance == nil or distance < smallestDistance then + smallestDistance = distance + result = matColor end end + return result + end + + -- Returns the color of the player's hand that is seated next to the playmat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + PlaymatApi.getPlayerColor = function(matColor) + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.getVar("playerColor") + end end - -- 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 = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.getVar("playerColor") - end - - -- Returns the color of the playermat that owns the playercolor's hand - ---@param handColor String Color of the playermat + -- Returns the color of the playmat that owns the playercolor's hand + ---@param handColor String Color of the playmat PlaymatApi.getMatColor = function(handColor) - local matColors = {"White", "Orange", "Green", "Red"} - for i, mat in ipairs(internal.getMatForColor("All")) do - local color = mat.getVar("playerColor") - if color == handColor then return matColors[i] end + for matColor, mat in pairs(internal.getMatForColor("All")) do + local playerColor = mat.getVar("playerColor") + if playerColor == handColor then return matColor end end return "NOT_FOUND" end - -- 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 = 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 + -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.getVar("isDES") + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.getVar("isDES") + end end -- Returns the draw deck of the requested playmat - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDrawDeck = function(matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - mat.call("getDrawDiscardDecks") - return mat.getVar("drawDeck") + for _, mat in pairs(internal.getMatForColor(matColor)) do + mat.call("getDrawDiscardDecks") + return mat.getVar("drawDeck") + end end -- Returns the position of the discard pile of the requested playmat - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.call("returnGlobalDiscardPosition") + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.call("returnGlobalDiscardPosition") + end end -- Transforms a local position into a global position ---@param localPos Table Local position to be transformed - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.positionToWorld(localPos) + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.positionToWorld(localPos) + end end -- Returns the rotation of the requested playmat - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.getRotation() + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.getRotation() + end end -- Triggers the Upkeep for the requested playmat - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.call("doUpkeepFromHotkey", playerColor) + for _, mat in pairs(internal.getMatForColor(matColor)) do + mat.call("doUpkeepFromHotkey", playerColor) + end end -- Returns the active investigator id - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.getVar("activeInvestigatorId") + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.getVar("activeInvestigatorId") + end end - -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If + -- Sets the requested playmat's snap points to limit snapping to matching card types or not. If -- matchTypes is true, the main card slot snap points will only snap assets, while the -- investigator area point will only snap Investigators. 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 matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will apply the setting to all four mats. + ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end - -- Sets the requested playermat's draw 1 button to visible - ---@param isDrawButtonVisible Boolean. Whether the draw 1 button should be visible or not - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will apply the setting to all four mats. + -- Sets the requested playmat's draw 1 button to visible + ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end - -- Shows or hides the clickable clue counter for the requested playermat - ---@param showCounter Boolean. Whether the clickable counter should be present or not - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will apply the setting to all four mats. + -- Shows or hides the clickable clue counter for the requested playmat + ---@param showCounter Boolean Whether the clickable counter should be present or not + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end - -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playermat - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will apply the setting to all four mats. + -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("removeClues") end end - -- Reports the clue count for the requested playermat + -- Reports the clue count for the requested playmat ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do count = count + tonumber(mat.call("getClueCount", useClickableCounters)) end return count end -- updates the specified owned counter - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will return all four mats. + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param type String Counter to target ---@param newValue Number Value to set the counter to ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier}) end end -- returns the resource counter amount - ---@param matColor String Color of the playermat + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") ---@param type String Counter to target PlaymatApi.getCounterValue = function(matColor, type) - local mat = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) - return mat.call("getCounterValue", type) + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.call("getCounterValue", type) + end end - -- resets the specified skill tracker to "1, 1, 1, 1" - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will return all four mats. + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("resetSkillTracker") end end + -- finds all objects on the playmat and associated set aside zone and returns a table + ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param filter Function Optional filter function (return true for desired objects) + PlaymatApi.searchAroundPlaymat = function(matColor, filter) + for _, mat in pairs(internal.getMatForColor(matColor)) do + return mat.call("searchAroundSelf", filter) + end + end + -- Discard a non-hidden card from the corresponding player's hand + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("doDiscardOne") end end + -- Triggers the metadata sync for all playmats PlaymatApi.syncAllCustomizableCards = function() - for _, mat in ipairs(internal.getMatForColor("All")) do + for _, mat in pairs(internal.getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end - PlaymatApi.updateClueClicker = function(matColor, 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. - ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also - -- accepts "All" as a special value which will return all four mats. - ---@return: Array of playermat objects. If a single mat is requested, will return a single-element - -- array to simplify processing by consumers. + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@return array Table Single-element if only single playmat is requested internal.getMatForColor = function(matColor) if matColor == "All" then return { - 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"}) + White = Global.call("getObjectFromMemo", {matColor = "White", type = "Playermat"}), + Orange = Global.call("getObjectFromMemo", {matColor = "Orange", type = "Playermat"}), + Green = Global.call("getObjectFromMemo", {matColor = "Green", type = "Playermat"}), + Red = Global.call("getObjectFromMemo", {matColor = "Red", type = "Playermat"}) } else - return { Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) } + return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) } end end From 947bf1dc4c1ee05e66ebc291f4a33acdb2961834 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 00:31:23 +0200 Subject: [PATCH 11/76] api cleanup --- src/chaosbag/BlessCurseManagerApi.ttslua | 22 +++--- src/core/DoomInPlayCounter.ttslua | 88 ++++++++++-------------- src/core/PlayAreaApi.ttslua | 46 +++++++------ 3 files changed, 71 insertions(+), 85 deletions(-) diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index d6c8a9f0..639fe7d8 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,9 +1,14 @@ do local BlessCurseManagerApi = {} + local internal = {} + + internal.getManager = function() + return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) + end -- removes all taken tokens and resets the counts BlessCurseManagerApi.removeTakenTokensAndReset = function() - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) + local BlessCurseManager = internal.getManager() 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) @@ -11,35 +16,30 @@ do -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.sealedToken = function(type, guid) - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) - BlessCurseManager.call("sealedToken", { type = type, guid = guid }) + internal.getManager().call("sealedToken", { type = type, guid = guid }) end -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.releasedToken = function(type, guid) - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) - BlessCurseManager.call("releasedToken", { type = type, guid = guid }) + internal.getManager().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) - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) - BlessCurseManager.call("broadcastStatus", playerColor) + internal.getManager().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) - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) - BlessCurseManager.call("doRemove", playerColor) + internal.getManager().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) - local BlessCurseManager = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) - BlessCurseManager.call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) + internal.getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) end return BlessCurseManagerApi diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index d0509a9a..8ba806f7 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,20 +1,9 @@ --- common parameters -local castParameters = {} -castParameters.direction = { 0, 1, 0 } -castParameters.type = 3 -castParameters.max_distance = 0 +local playmatApi = require("playermat/PlaymatApi") -local zone +local ZONE, TRASH local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" - --- playermats 1 to 4 -local originAndSize = { - { origin = { -55, 1.6, 16.5 }, size = { 12, 1, 25 } }, - { origin = { -55, 1.6, -16.5 }, size = { 12, 1, 25 } }, - { origin = { -25, 1.6, 27 }, size = { 25, 1, 12 } }, - { origin = { -25, 1.6, -27 }, size = { 25, 1, 12 } } -} +local COLORS = { "White", "Orange", "Green", "Red" } -- create button, context menu and start loop function onLoad() @@ -31,33 +20,32 @@ function onLoad() color = { 0, 0, 0, 0 } }) - zone = getObjectFromGUID("a2f932") + trash = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) + ZONE = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"}) loopID = Wait.time(countDoom, 2, -1) end -- main function function countDoom() local doom = 0 - for i = 1, 5 do doom = doom + search(i) end + for i = 1, 5 do + if i = 5 then + objList = ZONE.getObjects() + else + objList = playmatApi.searchAroundPlaymat(COLORS[i]) + end + + doom = doom + countDoomFromList(objList) + end self.editButton({ index = 0, label = tostring(doom) }) end --- searches playermats (num = 1-4) or the scripting zone (num = 5) -function search(num) - local val = 0 - if num == 5 then - for _, obj in ipairs(zone.getObjects()) do - val = val + isDoom(obj) - end - else - castParameters.origin = originAndSize[num].origin - castParameters.size = originAndSize[num].size - - for _, obj in ipairs(Physics.cast(castParameters)) do - val = val + isDoom(obj.hit_object) - end +function countDoomFromList(objList) + local count = 0 + for _, obj in ipairs(objList) do + count = count + isDoom(obj) end - return val + return count end -- checks an object for the doom image and gets quantity (for stacks) @@ -73,34 +61,30 @@ end -- removes doom from playermats / playarea function removeDoom(options) - local trashCan = getObjectFromGUID("70b9f6") local count = 0 + if options.Playermats then for i = 1, 4 do - castParameters.origin = originAndSize[i].origin - castParameters.size = originAndSize[i].size - - for _, obj in ipairs(Physics.cast(castParameters)) do - local obj = obj.hit_object - local amount = isDoom(obj) - if amount > 0 then - trashCan.putObject(obj) - count = count + amount - end - end + count = removeDoomFromList(playmatApi.searchAroundPlaymat(COLORS[i])) end broadcastToAll(count .. " doom removed from Playermats.", "White") end - local count = 0 if options.Playarea then - for _, obj in ipairs(zone.getObjects()) do - local amount = isDoom(obj) - if amount > 0 then - trashCan.putObject(obj) - count = count + amount - end - end - broadcastToAll(count .. " doom removed from Playarea.", "White") + count = removeDoomFromList(ZONE.getObjects()) + broadcastToAll(count .. " doom removed from Playerarea.", "White") end end + +-- removes doom from provided object list and returns the removed amount +function removeDoomFromList(objList) + local count = 0 + for _, obj in ipairs(objList) do + local amount = isDoom(obj) + if amount > 0 then + TRASH.putObject(obj) + count = count + amount + end + end + return count +end diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 829b6f6f..7be3c6a4 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,5 +1,10 @@ do - local PlayAreaApi = { } + local PlayAreaApi = {} + local internal = {} + + internal.getPlayArea = function() + return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}) + end -- Returns the current value of the investigator counter from the playmat ---@return Integer. Number of investigators currently set on the counter @@ -14,90 +19,87 @@ do end -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain - -- fixed objects will be ignored, as will anything the player has tagged with - -- 'displacement_excluded' - ---@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 + -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' + ---@param playerColor Color Color of the player requesting the shift for messages PlayAreaApi.shiftContentsUp = function(playerColor) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsUp", playerColor) + return internal.getPlayArea().call("shiftContentsUp", playerColor) end PlayAreaApi.shiftContentsDown = function(playerColor) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsDown", playerColor) + return internal.getPlayArea().call("shiftContentsDown", playerColor) end PlayAreaApi.shiftContentsLeft = function(playerColor) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsLeft", playerColor) + return internal.getPlayArea().call("shiftContentsLeft", playerColor) end PlayAreaApi.shiftContentsRight = function(playerColor) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("shiftContentsRight", playerColor) + return internal.getPlayArea().call("shiftContentsRight", playerColor) end -- Reset the play area's tracking of which cards have had tokens spawned. PlayAreaApi.resetSpawnedCards = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("resetSpawnedCards") + return internal.getPlayArea().call("resetSpawnedCards") end -- Event to be called when the current scenario has changed. ---@param scenarioName Name of the new scenario PlayAreaApi.onScenarioChanged = function(scenarioName) - Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("onScenarioChanged", scenarioName) + internal.getPlayArea().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) - Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("setLimitSnapsByType", matchCardTypes) + internal.getPlayArea().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) - Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("tryObjectEnterContainer", - { container = container, object = object }) + internal.getPlayArea().call("tryObjectEnterContainer", { container = container, object = object }) end -- counts the VP on locations in the play area PlayAreaApi.countVP = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("countVP") + return internal.getPlayArea().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 Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("highlightMissingData", state) + return internal.getPlayArea().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 Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("highlightCountedVP", state) + return internal.getPlayArea().call("highlightCountedVP", state) end -- Checks if an object is in the play area (returns true or false) PlayAreaApi.isInPlayArea = function(object) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("isInPlayArea", object) + return internal.getPlayArea().call("isInPlayArea", object) end PlayAreaApi.getSurface = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).getCustomObject().image + return internal.getPlayArea().getCustomObject().image end PlayAreaApi.updateSurface = function(url) - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("updateSurface", url) + return internal.getPlayArea().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) - Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).call("updateLocations", args) + internal.getPlayArea().call("updateLocations", args) end PlayAreaApi.getCustomDataHelper = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}).getVar("customDataHelper") + return internal.getPlayArea().getVar("customDataHelper") end return PlayAreaApi From 9a1898ca4dd28bf1f7bfe2b41c731d133dc667ca Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 00:40:25 +0200 Subject: [PATCH 12/76] countDoom() bugfix --- src/core/DoomInPlayCounter.ttslua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 8ba806f7..33977e0a 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,6 +1,6 @@ local playmatApi = require("playermat/PlaymatApi") -local ZONE, TRASH +local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" local COLORS = { "White", "Orange", "Green", "Red" } @@ -28,15 +28,10 @@ end -- main function function countDoom() local doom = 0 - for i = 1, 5 do - if i = 5 then - objList = ZONE.getObjects() - else - objList = playmatApi.searchAroundPlaymat(COLORS[i]) - end - - doom = doom + countDoomFromList(objList) + for i = 1, 4 do + doom = doom + countDoomFromList(playmatApi.searchAroundPlaymat(COLORS[i])) end + doom = doom + countDoomFromList(ZONE.getObjects()) self.editButton({ index = 0, label = tostring(doom) }) end @@ -69,7 +64,7 @@ function removeDoom(options) end broadcastToAll(count .. " doom removed from Playermats.", "White") end - + if options.Playarea then count = removeDoomFromList(ZONE.getObjects()) broadcastToAll(count .. " doom removed from Playerarea.", "White") From 0fedc74ded87f0794204ae83948962f742ded2da Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 01:05:30 +0200 Subject: [PATCH 13/76] made campaign importer export dynamic --- objects/SCEDTour.0e5aa8.json | 1 + .../CampaignImporterExporter.ttslua | 155 ++++++++---------- 2 files changed, 70 insertions(+), 86 deletions(-) diff --git a/objects/SCEDTour.0e5aa8.json b/objects/SCEDTour.0e5aa8.json index 8709156c..c75ad261 100644 --- a/objects/SCEDTour.0e5aa8.json +++ b/objects/SCEDTour.0e5aa8.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/tour/TourStarter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TourStarter\"}", "Name": "Custom_Token", "Nickname": "SCED Tour", "Snap": true, diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 5d7c9a4e..4562a840 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -1,11 +1,11 @@ -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 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 playmatApi = require("playermat/PlaymatApi") local campaignTokenData = { - GUID = "51b1c9", Name = "Custom_Model", Transform = { posX = -21.25, @@ -18,9 +18,7 @@ local campaignTokenData = { scaleY = 2, scaleZ = 2 }, - Nickname = "Arkham Coin", Description = "SCED Importer Token", - GMNotes = "", Tags = { "ImporterToken" }, @@ -33,56 +31,47 @@ local campaignTokenData = { MaterialIndex = 2, TypeIndex = 0, CustomShader = { - SpecularColor = { - r = 0.7222887, - g = 0.507659256, - b = 0.339915335 - }, - SpecularIntensity = 0.4, - SpecularSharpness = 7.0, - FresnelStrength = 0.0 + SpecularColor = { + r = 0.7222887, + g = 0.507659256, + b = 0.339915335 + }, + SpecularIntensity = 0.4, + SpecularSharpness = 7.0, + FresnelStrength = 0.0 }, CastShadows = true } } --- counter GUIDS (4x damage and 4x horror) -local DAMAGE_HORROR_GUIDS = { - "eb08d6"; "e64eec"; "1f5a0a"; "591a45"; - "468e88"; "0257d9"; "7b5729"; "beb964"; - } - -local TOUR_GUID = "0e5aa8" -local campaignBoxGUID - -function onLoad(save_state) - campaignBoxGUID = "" - +function onLoad() self.createButton({ click_function = "findCampaignFromToken", function_owner = self, label = "Import", - tooltip = "Load in a campaign save from a token!\n\n(Token can be anywhere on the table, but ensure there is only 1!)", - position = {x=-1, y=0.2, z=0}, + tooltip = "Load in a campaign save from a token!\n\n(Token can be anywhere on the table, but ensure there is only 1!)", + position = { x = -1, y = 0.2, z = 0 }, font_size = 400, width = 1400, height = 600, - scale = {0.5, 1, 0.5}, + scale = { 0.5, 1, 0.5 }, }) self.createButton({ click_function = "createCampaignToken", function_owner = self, label = "Export", tooltip = "Create a campaign save token!\n\n(Ensure all chaos tokens have been unsealed!)", - position = {x=1, y=0.2, z=0}, + position = { x = 1, y = 0.2, z = 0 }, font_size = 400, width = 1400, height = 600, - scale = {0.5, 1, 0.5}, + scale = { 0.5, 1, 0.5 }, }) end --- The main import functions. Due to timing concerns, has to be split up into several separate methods to allow for Wait conditions +--------------------------------------------------------- +-- main import functions (split up to allow for Wait conditions) +--------------------------------------------------------- -- Identifies import token, determines campaign box and downloads it (if needed) function findCampaignFromToken(_, _, _) @@ -91,11 +80,13 @@ function findCampaignFromToken(_, _, _) if #coinObjects == 0 then broadcastToAll("Could not find importer token", Color.Red) elseif #coinObjects > 1 then - broadcastToAll("More than 1 importer token found. Please delete all but 1 importer token", Color.Yellow) + broadcastToAll("More than 1 importer token found. Please delete all but 1 importer token", Color.Yellow) else coin = coinObjects[1] + local importData = JSON.decode(coin.getGMNotes()) campaignBoxGUID = importData["box"] + local campaignBox = getObjectFromGUID(campaignBoxGUID) if campaignBox.type == "Generic" then campaignBox.call("buttonClick_download") @@ -110,21 +101,21 @@ function findCampaignFromToken(_, _, _) end, function() local obj = getObjectFromGUID(campaignBoxGUID) - if obj == nil then - return false + if obj == nil then + return false else return obj.type == "Bag" and obj.getLuaScript() ~= "" end end, 2, function() broadcastToAll("Error loading campaign box") end - ) + ) end end -- After box has been downloaded, places content on table function placeCampaignFromToken(importData) - getObjectFromGUID(campaignBoxGUID).call("buttonClick_place") + getObjectFromGUID(importData["box"]).call("buttonClick_place") Wait.condition( function() createCampaignFromToken(importData) end, function() return findCampaignLog() ~= nil end, @@ -135,30 +126,33 @@ end -- After content is placed on table, conducts all the other import operations function createCampaignFromToken(importData) + -- destroy existing campaign log and load saved campaign log findCampaignLog().destruct() - --create campaign log - spawnObjectData({data = importData["log"]}) - --create chaos bag + spawnObjectData({ data = importData["log"] }) + chaosBagApi.setChaosBagState(importData["bag"]) - --populate trauma values + + -- populate trauma values if importData["trauma"] then - updateCounters(importData["trauma"]) + setTrauma(importData["trauma"]) end - --populate ArkhamDB deck IDs + + -- populate ArkhamDB deck IDs if importData["decks"] then deckImporterApi.setUiState(importData["decks"]) end - --set investigator count + playAreaApi.setInvestigatorCount(importData["clueCount"]) - --set campaign guide page + + -- set campaign guide page local guide = findCampaignGuide() if guide then Wait.condition( - -- Called after the condition function returns true + -- Called after the condition function returns true function() log("Campaign Guide import successful!") end, - -- Condition function that is called continiously until returs true or timeout is reached + -- Condition function that is called continiously until returs true or timeout is reached function() guide.Book.setPage(importData["guide"]) return guide.Book.getPage() == importData["guide"] @@ -171,16 +165,18 @@ function createCampaignFromToken(importData) end ) end - Wait.time( - function() optionPanelApi.loadSettings(importData["options"]) end, - 0.5 - ) - getObjectFromGUID(TOUR_GUID).destruct() + + Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5) + + -- destroy Tour Starter token + Global.call("getObjectFromMemo", { matColor = "Mythos", type = "TourStarter" }).destruct() + + -- restore PlayArea image playAreaApi.updateSurface(importData["playmat"]) + broadcastToAll("Campaign successfully imported!", Color.Green) end - -- Creates a campaign token with save data encoded into GM Notes based on the current state of the table function createCampaignToken(_, playerColor, _) -- clean up chaos tokens @@ -207,10 +203,12 @@ function createCampaignToken(_, playerColor, _) broadcastToAll("Campaign log not found!", Color.Red) return end - local traumaValues = nil + local traumaValues = { + 0, 0, 0, 0, + 0, 0, 0, 0 + } local counterData = campaignLog.getVar("ref_buttonData") if counterData ~= nil then - traumaValues = {} printToAll("Trauma values found in campaign log!", "Green") for i = 1, 10, 3 do traumaValues[1 + (i - 1) / 3] = counterData.counter[i].value @@ -225,7 +223,6 @@ function createCampaignToken(_, playerColor, _) broadcastToAll("Campaign guide not found!", Color.Red) return end - local campaignGuidePage = campaignGuide.Book.getPage() local campaignData = { box = campaignBoxGUID, log = campaignLog.getData(), @@ -233,27 +230,25 @@ function createCampaignToken(_, playerColor, _) trauma = traumaValues, decks = deckImporterApi.getUiState(), clueCount = playAreaApi.getInvestigatorCount(), - guide = campaignGuidePage, + guide = campaignGuide.Book.getPage(), options = optionPanelApi.getOptions(), playmat = playAreaApi.getSurface() } campaignTokenData.GMNotes = JSON.encode(campaignData) campaignTokenData.Nickname = os.date("%b %d ") .. getObjectFromGUID(campaignBoxGUID).getName() .. " Save" - spawnObjectData({ - data = campaignTokenData, - position = {-21.25, 1.68, 55.59} - }) + spawnObjectData({ data = campaignTokenData }) broadcastToAll("Campaign successfully exported! Save coin object to import on a fresh save", Color.Green) end - +--------------------------------------------------------- -- helper functions +--------------------------------------------------------- function findCampaignLog() local campaignLog = getObjectsWithTag("CampaignLog") if campaignLog then if #campaignLog == 1 then - return campaignLog[1] + return campaignLog[1] else broadcastToAll("More than 1 campaign log detected; delete all but one.", Color.Red) return nil @@ -263,35 +258,23 @@ function findCampaignLog() end end -function findCampaignGuide() +function findCampaignGuide() local campaignGuide = getObjectsWithTag("CampaignGuide") if campaignGuide then if #campaignGuide == 1 then return campaignGuide[1] - else - broadcastToAll("More than 1 campaign guide detected; delete all but one.", Color.Red) - return nil - end + else + broadcastToAll("More than 1 campaign guide detected; delete all but one.", Color.Red) + return nil + end else return nil end end -function updateCounters(tableOfNewValues) - if tonumber(tableOfNewValues) then - local value = tableOfNewValues - tableOfNewValues = {} - for i = 1, #DAMAGE_HORROR_GUIDS do - table.insert(tableOfNewValues, value) - end - end - - for i, guid in ipairs(DAMAGE_HORROR_GUIDS) do - local TOKEN = getObjectFromGUID(guid) - if TOKEN ~= nil then - TOKEN.call("updateVal", tableOfNewValues[i]) - else - printToAll(": No. " .. i .. " could not be found.", "Yellow") - end +function setTrauma(trauma) + for i = 1, 4 do + playmatApi.updateCounter(COLORS[i], "DamageCounter", trauma[i]) + playmatApi.updateCounter(COLORS[i], "HorrorCounter", trauma[i + 4]) end end From b1cff2fc285255bbbe1b53f2297ca1b7942456a5 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 01:17:57 +0200 Subject: [PATCH 14/76] removed GUID reference from Token Spawn Tracker --- objects/TokenSpawnTracker.e3ffc9.json | 1 + src/core/token/TokenSpawnTrackerApi.ttslua | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/objects/TokenSpawnTracker.e3ffc9.json b/objects/TokenSpawnTracker.e3ffc9.json index 0c4e1527..8709a748 100644 --- a/objects/TokenSpawnTracker.e3ffc9.json +++ b/objects/TokenSpawnTracker.e3ffc9.json @@ -24,6 +24,7 @@ "LuaScript": "require(\"core/token/TokenSpawnTracker\")", "LuaScriptState": "{\"cards\":[]}", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenSpawnTracker\"}", "Name": "Checker_white", "Nickname": "Token Spawn Tracker", "Snap": true, diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index dd8d7002..c8f8407d 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,29 +1,33 @@ do - local TokenSpawnTracker = { } - local SPAWN_TRACKER_GUID = "e3ffc9" + local TokenSpawnTracker = {} + local internal = {} + + internal.getSpawnTracker = function() + return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSpawnTracker"}) + end TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("hasSpawnedTokens", cardGuid) + return internal.getSpawnTracker().call("hasSpawnedTokens", cardGuid) end TokenSpawnTracker.markTokensSpawned = function(cardGuid) - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("markTokensSpawned", cardGuid) + return internal.getSpawnTracker().call("markTokensSpawned", cardGuid) end TokenSpawnTracker.resetTokensSpawned = function(cardGuid) - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("resetTokensSpawned", cardGuid) + return internal.getSpawnTracker().call("resetTokensSpawned", cardGuid) end TokenSpawnTracker.resetAllAssetAndEvents = function() - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("resetAllAssetAndEvents") + return internal.getSpawnTracker().call("resetAllAssetAndEvents") end TokenSpawnTracker.resetAllLocations = function() - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("resetAllLocations") + return internal.getSpawnTracker().call("resetAllLocations") end TokenSpawnTracker.resetAll = function() - return getObjectFromGUID(SPAWN_TRACKER_GUID).call("resetAll") + return internal.getSpawnTracker().call("resetAll") end return TokenSpawnTracker From 2d85f913b1a749412e321c7279a7ece4a2da4700 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 01:56:34 +0200 Subject: [PATCH 15/76] doom counter update --- src/core/DoomInPlayCounter.ttslua | 56 +++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 33977e0a..d3fa9a02 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -20,38 +20,60 @@ function onLoad() color = { 0, 0, 0, 0 } }) - trash = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) - ZONE = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"}) + trash = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" }) + ZONE = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "PlayAreaZone" }) loopID = Wait.time(countDoom, 2, -1) end -- main function function countDoom() - local doom = 0 - for i = 1, 4 do - doom = doom + countDoomFromList(playmatApi.searchAroundPlaymat(COLORS[i])) + local objList = {} + + -- get doom objects in play area zone + for _, obj in ipairs(ZONE.getObjects()) do + if filterDoom(obj) then + table.insert(objList, obj) + end end - doom = doom + countDoomFromList(ZONE.getObjects()) + + -- get doom objects on playmats + for i = 1, 4 do + local playmatList = playmatApi.searchAroundPlaymat(COLORS[i]) + for _, obj in ipairs(playmatList) do + if filterDoom(obj) then + table.insert(objList, obj) + end + end + end + + local doom = countDoomFromList(objList) self.editButton({ index = 0, label = tostring(doom) }) end function countDoomFromList(objList) local count = 0 for _, obj in ipairs(objList) do - count = count + isDoom(obj) + count = count + getDoomAmount(obj) end return count end --- checks an object for the doom image and gets quantity (for stacks) -function isDoom(obj) - if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL) or - (obj.name == "Custom_Token" and obj.getCustomObject().image == doomURL) then - if not obj.hasTag(IGNORE_TAG) then - return math.abs(obj.getQuantity()) - end +function filterDoom(obj) + if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL) + or (obj.name == "Custom_Token" and obj.getCustomObject().image == doomURL) then + return true + else + return false + end +end + +-- gets quantity (for stacks) of doom +function getDoomAmount(obj) + if not obj.hasTag(IGNORE_TAG) then + return math.abs(obj.getQuantity()) + else + return 0 end - return 0 end -- removes doom from playermats / playarea @@ -64,7 +86,7 @@ function removeDoom(options) end broadcastToAll(count .. " doom removed from Playermats.", "White") end - + if options.Playarea then count = removeDoomFromList(ZONE.getObjects()) broadcastToAll(count .. " doom removed from Playerarea.", "White") @@ -75,7 +97,7 @@ end function removeDoomFromList(objList) local count = 0 for _, obj in ipairs(objList) do - local amount = isDoom(obj) + local amount = getDoomAmount(obj) if amount > 0 then TRASH.putObject(obj) count = count + amount From 18c06b4691bd27b6d0d42b54a599ae795234d354 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 13:59:34 +0200 Subject: [PATCH 16/76] more dynamic references --- objects/MasterClueCounter.4a3aa4.json | 1 + objects/OtherDoominPlay.652ff3.json | 1 + src/core/DoomCounter.ttslua | 3 +- src/core/GameKeyHandler.ttslua | 2 +- src/core/Global.ttslua | 2 +- src/core/token/TokenSpawnTracker.ttslua | 68 ++++++++++--------------- src/playermat/Zones.ttslua | 17 ++----- 7 files changed, 37 insertions(+), 57 deletions(-) diff --git a/objects/MasterClueCounter.4a3aa4.json b/objects/MasterClueCounter.4a3aa4.json index 69d25c0f..f5612158 100644 --- a/objects/MasterClueCounter.4a3aa4.json +++ b/objects/MasterClueCounter.4a3aa4.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/MasterClueCounter\")", "LuaScriptState": "false", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"MasterClueCounter\"}", "Name": "Custom_Token", "Nickname": "Master Clue Counter", "Snap": true, diff --git a/objects/OtherDoominPlay.652ff3.json b/objects/OtherDoominPlay.652ff3.json index 6150163c..3bde1d78 100644 --- a/objects/OtherDoominPlay.652ff3.json +++ b/objects/OtherDoominPlay.652ff3.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"core/DoomInPlayCounter\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DoomInPlayCounter\"}", "Name": "Custom_Token", "Nickname": "Other Doom in Play", "Snap": true, diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index 9d7efd2b..dff220b4 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -64,8 +64,7 @@ function startReset() if options.Agenda then updateVal(0) end - -- call the "Doom-in-Play"-counter - local DoomInPlayCounter = getObjectFromGUID("652ff3") + local DoomInPlayCounter = getObjectFromMemo({matColor = "Mythos", type = "DoomInPlayCounter"}) if DoomInPlayCounter then DoomInPlayCounter.call("removeDoom", options) end diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 2ee982c3..70ff89f8 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -41,7 +41,7 @@ end -- adds 1 doom to the agenda function addDoomToAgenda() - getObjectFromGUID("85c4c6").call("addVal", 1) + getObjectFromMemo({matColor = "Mythos", type = "DoomCounter"}).call("addVal", 1) end -- moves the hovered card to the victory display diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 00c974ca..92d13010 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -922,7 +922,7 @@ function applyOptionPanelChange(id, state) optionPanel[id] = state -- update master clue counter - getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state) + getObjectFromMemo({matColor = "Mythos", type = "MasterClueCounter"}).setVar("useClickableCounters", state) -- option: Play area snap tags elseif id == "playAreaSnapTags" then diff --git a/src/core/token/TokenSpawnTracker.ttslua b/src/core/token/TokenSpawnTracker.ttslua index c8186937..6c9fc9eb 100644 --- a/src/core/token/TokenSpawnTracker.ttslua +++ b/src/core/token/TokenSpawnTracker.ttslua @@ -1,26 +1,15 @@ -local spawnedCardGuids = { } +local spawnedCardGuids = {} -local HAND_ZONES = { } -HAND_ZONES["a70eee"] = true -- White -HAND_ZONES["0285cc"] = true -- Green -HAND_ZONES["5fe087"] = true -- Orange -HAND_ZONES["be2f17"] = true -- Red +function onSave() return JSON.encode({ cards = spawnedCardGuids }) end function onLoad(saveState) if saveState ~= nil then - local saveTable = JSON.decode(saveState) or { } - spawnedCardGuids = saveTable.cards or { } + local saveTable = JSON.decode(saveState) or {} + spawnedCardGuids = saveTable.cards or {} end - createResetMenuItems() end -function onSave() - return JSON.encode({ - cards = spawnedCardGuids - }) -end - function createResetMenuItems() self.addContextMenuItem("Reset All", resetAll) self.addContextMenuItem("Reset Locations", resetAllLocations) @@ -39,14 +28,20 @@ function resetTokensSpawned(cardGuid) spawnedCardGuids[cardGuid] = nil end -function resetAllAssetAndEvents() - local resetList = { } +function resetAll() spawnedCardGuids = {} end + +function resetAllLocations() resetSpecificTypes("Location") end + +function resetAllAssetAndEvents() resetSpecificTypes("Asset", "Event") end + +function resetSpecificTypes(type1, type2) + local resetList = {} for cardGuid, _ in pairs(spawnedCardGuids) do local card = getObjectFromGUID(cardGuid) if card ~= nil then - local cardMetadata = JSON.decode(card.getGMNotes()) or { } + local cardMetadata = JSON.decode(card.getGMNotes()) or {} -- Check this by type rather than the PlayerCard tag so we don't reset weaknesses - if cardMetadata.type == "Asset" or cardMetadata.type == "Event" then + if cardMetadata.type == type1 or cardMetadata.type == type2 then resetList[cardGuid] = true end end @@ -56,30 +51,21 @@ function resetAllAssetAndEvents() end end -function resetAllLocations() - local resetList = { } - for cardGuid, _ in pairs(spawnedCardGuids) do - local card = getObjectFromGUID(cardGuid) - if card ~= nil then - local cardMetadata = JSON.decode(card.getGMNotes()) or { } - -- Check this by type rather than the PlayerCard tag so we don't reset weaknesses - if cardMetadata.type == "Location" then - resetList[cardGuid] = true - end - end - end - for cardGuid, _ in pairs(resetList) do - spawnedCardGuids[cardGuid] = nil - end -end - -function resetAll() - spawnedCardGuids = { } -end - -- Listener to reset card token spawns when they enter a hand. function onObjectEnterZone(zone, enterObject) - if HAND_ZONES[zone.getGUID()] then + if checkMemo(zone) then resetTokensSpawned(enterObject.getGUID()) end end + +-- checks if the object is owned by a playermat +function checkMemo(obj) + local memo = obj.getMemo() + if memo then + local decoded = JSON.decode(memo) or {} + if decoded.matColor ~= "Mythos" then + return true + end + end + return false +end diff --git a/src/playermat/Zones.ttslua b/src/playermat/Zones.ttslua index 2cb978d9..41a97373 100644 --- a/src/playermat/Zones.ttslua +++ b/src/playermat/Zones.ttslua @@ -20,14 +20,9 @@ -- SetAside5: Hunch Deck for Joe Diamond -- SetAside6: currently unused do + local playmatApi = require("playermat/PlaymatApi") local Zones = { } - local playerMatGuids = {} - playerMatGuids["Red"] = "0840d5" - playerMatGuids["Orange"] = "bd0ff4" - playerMatGuids["White"] = "8b081b" - playerMatGuids["Green"] = "383d8b" - local commonZones = {} commonZones["Investigator"] = { -1.17702, 0, 0.00209 } commonZones["Deck"] = { -1.822724, 0, -0.02940192 } @@ -119,7 +114,7 @@ do and playerColor ~= "Green") then return nil end - return getObjectFromGUID(playerMatGuids[playerColor]).positionToWorld(zoneData[playerColor][zoneName]) + return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor) end -- Return the global rotation for a card on the given player mat, based on its metadata. @@ -129,13 +124,11 @@ do -- Y rotation to orient the card on the given player mat as well as a -- Z rotation to place the card face up or face down. Zones.getDefaultCardRotation = function(playerColor, zone) - local deckRotation = getObjectFromGUID(playerMatGuids[playerColor]).getRotation() - + local cardRotation = playmatApi.returnRotation(playerColor) if zone == "Deck" then - deckRotation = deckRotation + Vector(0, 0, 180) + cardRotation = cardRotation + Vector(0, 0, 180) end - - return deckRotation + return cardRotation end return Zones From accf9d7197d56bcce291667ba4ae6c22ff23783e Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 18:37:55 +0200 Subject: [PATCH 17/76] dynamic tourscript --- objects/PlayerCards.2d30ee.json | 1 + objects/Resourcetokens.9fadf9.json | 1 + objects/RulesReference.d99993.json | 1 + objects/ThePathtoCarcosa.aca04c.json | 1 + src/core/tour/TourManager.ttslua | 4 ++-- src/core/tour/TourScript.ttslua | 10 +++++----- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/objects/PlayerCards.2d30ee.json b/objects/PlayerCards.2d30ee.json index 94839147..f05bd54c 100644 --- a/objects/PlayerCards.2d30ee.json +++ b/objects/PlayerCards.2d30ee.json @@ -36,6 +36,7 @@ "LuaScript": "require(\"playercards/PlayerCardPanel\")", "LuaScriptState": "{\"spawnBagState\":{\"placed\":[],\"placedObjects\":[]}}", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayerCardPanel\"}", "Name": "Custom_Tile", "Nickname": "Player Cards", "Snap": true, diff --git a/objects/Resourcetokens.9fadf9.json b/objects/Resourcetokens.9fadf9.json index 06da43f5..a39181d0 100644 --- a/objects/Resourcetokens.9fadf9.json +++ b/objects/Resourcetokens.9fadf9.json @@ -39,6 +39,7 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"ResourceTokenBag\"}", "MeshIndex": -1, "Name": "Custom_Model_Infinite_Bag", "Nickname": "Resource tokens", diff --git a/objects/RulesReference.d99993.json b/objects/RulesReference.d99993.json index 4de14917..b00713d6 100644 --- a/objects/RulesReference.d99993.json +++ b/objects/RulesReference.d99993.json @@ -30,6 +30,7 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"RulesReference\"}", "Name": "Custom_PDF", "Nickname": "Rules Reference", "Snap": true, diff --git a/objects/ThePathtoCarcosa.aca04c.json b/objects/ThePathtoCarcosa.aca04c.json index dd39ca10..c7c855cd 100644 --- a/objects/ThePathtoCarcosa.aca04c.json +++ b/objects/ThePathtoCarcosa.aca04c.json @@ -45,6 +45,7 @@ "LuaScript": "require(\"core/DownloadBox\")", "LuaScriptState": "", "MeasureMovement": false, + "Memo": "{\"matColor\":\"Mythos\",\"type\":\"CampaignThePathToCarcosa\"}", "Name": "Custom_Model", "Nickname": "The Path to Carcosa", "Snap": true, diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index d0a37183..4f67e09a 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -123,8 +123,8 @@ do delay = delay + 0.5 end local lookPos - if TOUR_SCRIPT[cardIndex].showObj ~= nil then - local lookAtObj = getObjectFromGUID(TOUR_SCRIPT[cardIndex].showObj) + if TOUR_SCRIPT[cardIndex].objMemoData ~= nil then + local lookAtObj = Global.call("getObjectFromMemo", TOUR_SCRIPT[cardIndex].objMemoData) lookPos = lookAtObj.getPosition() lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0 -- Since camera isn't directly above the hook, changing the Y affects the visual position of diff --git a/src/core/tour/TourScript.ttslua b/src/core/tour/TourScript.ttslua index 2d92848a..d407de3c 100644 --- a/src/core/tour/TourScript.ttslua +++ b/src/core/tour/TourScript.ttslua @@ -15,7 +15,7 @@ TOUR_SCRIPT = { { narrator = "Daisy", text = "If you're new to the game, the library here has everything you'll need. A little research can go a long way, and looking into old newspapers for the weird and unusual can yield some surprisingly helpful information.\n\nI put a few right there that might prove enlightening.", - showObj = "d99993", + objMemoData = { matColor = "Mythos", type = "RulesReference" }, distanceFromObj = 20, position = "west", speakerSide = "right" @@ -23,7 +23,7 @@ TOUR_SCRIPT = { { narrator = "Mandy", text = "To survive what's coming you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here, and even find the newest version after an upgrade without changing the ID.\n\nNo need to publish all your decks, use 'Private' and you can see it. Just make sure to select 'Make your decks public' in ArkhamDB.", - showObj = "a28140", + objMemoData = { matColor = "Mythos", type = "DeckImporter" }, distanceFromObj = -5, position = "northwest", skipCentering = true, @@ -31,7 +31,7 @@ TOUR_SCRIPT = { { narrator = "Daniela", text = "I prefer the hands-on approach to building things, if you do too you can build a deck yourself.\n\nAll the cards you could ever need are here, laid out like a disassembled engine. Place the cards on the table, copy them for your deck, and you'll be ready for anything.", - showObj = "2d30ee", + objMemoData = { matColor = "Mythos", type = "PlayerCardPanel" }, distanceFromObj = -7, position = "south", speakerSide = "right" @@ -39,7 +39,7 @@ TOUR_SCRIPT = { { narrator = "Finn", text = "Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\n\nJust remember - if it turns out to be too much for you, I was never here.", - showObj = "aca04c", + objMemoData = = { matColor = "Mythos", type = "CampaignThePathToCarcosa" }, distanceFromObj = 20, position = "northwest", }, @@ -77,7 +77,7 @@ TOUR_SCRIPT = { { narrator = "Preston", text = "I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\n\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.", - showObj = "9fadf9", + objMemoData = = { matColor = "Mythos", type = "ResourceTokenBag" }, position = "north", skipCentering = true, speakerSide = "right" From a5589907db7d73d53ca1e9709eab668d82cec85c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 18:40:49 +0200 Subject: [PATCH 18/76] fixed typo --- src/core/tour/TourScript.ttslua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tour/TourScript.ttslua b/src/core/tour/TourScript.ttslua index d407de3c..203e7d05 100644 --- a/src/core/tour/TourScript.ttslua +++ b/src/core/tour/TourScript.ttslua @@ -39,7 +39,7 @@ TOUR_SCRIPT = { { narrator = "Finn", text = "Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\n\nJust remember - if it turns out to be too much for you, I was never here.", - objMemoData = = { matColor = "Mythos", type = "CampaignThePathToCarcosa" }, + objMemoData = { matColor = "Mythos", type = "CampaignThePathToCarcosa" }, distanceFromObj = 20, position = "northwest", }, @@ -77,7 +77,7 @@ TOUR_SCRIPT = { { narrator = "Preston", text = "I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\n\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.", - objMemoData = = { matColor = "Mythos", type = "ResourceTokenBag" }, + objMemoData = { matColor = "Mythos", type = "ResourceTokenBag" }, position = "north", skipCentering = true, speakerSide = "right" From 93bf6a8b61e308116d9c0238abb8e436b15fe2e7 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 19:37:56 +0200 Subject: [PATCH 19/76] well connected bugfix and refactor --- src/playercards/cards/WellConnected.ttslua | 72 ++++++++-------------- src/playermat/Playmat.ttslua | 2 +- 2 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/playercards/cards/WellConnected.ttslua b/src/playercards/cards/WellConnected.ttslua index 872a7c5a..31f90625 100644 --- a/src/playercards/cards/WellConnected.ttslua +++ b/src/playercards/cards/WellConnected.ttslua @@ -1,13 +1,10 @@ -- this script is shared between both the level 0 and the upgraded level 3 version of the card local playmatApi = require("playermat/PlaymatApi") -local display = false -local count = 0 -local modValue = 5 -- level 0 Well Connected -local loopId = nil - -local b_display = { +local modValue, loopId +local buttonParameters = { click_function = "toggleCounter", + tooltip = "disable counter", function_owner = self, position = { 0.88, 0.5, -1.33 }, font_size = 150, @@ -15,57 +12,42 @@ local b_display = { height = 175 } -function onLoad(saved_data) - local notes = JSON.decode(self.getGMNotes()) +function onSave() return JSON.encode({ loopId = loopId }) end - if notes.id == "54006" then -- hardcoded card id for upgraded Well Connected (3) - modValue = 4 -- Well Connected (3) +function onLoad(savedData) + -- use metadata to detect level and adjust modValue accordingly + if JSON.decode(self.getGMNotes()).level == 0 then + modValue = 5 + else + modValue = 4 end - if saved_data != '' then - local loaded_data = JSON.decode(saved_data) - display = not loaded_data.saved_display - - self.clearButtons() - toggleCounter() + if savedData ~= "" then + local loadedData = JSON.decode(savedData) + if loadedData.loopId then + self.createButton(buttonParameters) + loopId = Wait.time(updateDisplay, 2, -1) + end end - self.addContextMenuItem('Toggle Counter', toggleCounter) -end - -function onSave() - return JSON.encode({ saved_display = display }) + self.addContextMenuItem("Toggle Counter", toggleCounter) end function toggleCounter() - display = not display - - if display then - createUpdateDisplay() - loopId = Wait.time(createUpdateDisplay, 2, -1) - else - if loopId ~= nil then - Wait.stop(loopId) - end - - self.clearButtons() + if loopId ~= nil then + Wait.stop(loopId) loopId = nil - end -end - -function createUpdateDisplay() - count = math.max(math.floor(getPlayerResources() / modValue), 0) - - b_display.label = tostring(count) - - if loopId == nil then - self.createButton(b_display) + self.clearButtons() else - self.editButton(b_display) + self.createButton(buttonParameters) + updateDisplay() + loopId = Wait.time(updateDisplay, 2, -1) end end -function getPlayerResources() +function updateDisplay() local matColor = playmatApi.getMatColorByPosition(self.getPosition()) - return playmatApi.getCounterValue(matColor, "ResourceCounter") + local resources = playmatApi.getCounterValue(matColor, "ResourceCounter") + local count = tostring(math.floor(resources / modValue)) + self.editButton({ index = 0, label = count }) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 449aab2e..64137337 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -798,7 +798,7 @@ end -- returns the resource counter amount ---@param type String Counter to target function getCounterValue(type) - return ownedObjects.type.getVar("val") + return ownedObjects[type].getVar("val") end -- set investigator skill tracker to "1, 1, 1, 1" From 282a411ec206452acabd72a0cd8977ccdf96df7e Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 30 Sep 2023 20:09:00 +0200 Subject: [PATCH 20/76] campaign exporter update --- .../CampaignImporterExporter.ttslua | 71 +++++++------------ src/arkhamdb/DeckImporterUi.ttslua | 33 +-------- 2 files changed, 30 insertions(+), 74 deletions(-) diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 4562a840..8d6eeef2 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -43,6 +43,7 @@ local campaignTokenData = { CastShadows = true } } +local COLORS = { "White", "Orange", "Green", "Red" } function onLoad() self.createButton({ @@ -118,7 +119,7 @@ function placeCampaignFromToken(importData) getObjectFromGUID(importData["box"]).call("buttonClick_place") Wait.condition( function() createCampaignFromToken(importData) end, - function() return findCampaignLog() ~= nil end, + function() return findUniqueObjectWithTag("CampaignLog") ~= nil end, 2, function() broadcastToAll("Error placing campaign box") end ) @@ -127,9 +128,9 @@ end -- After content is placed on table, conducts all the other import operations function createCampaignFromToken(importData) -- destroy existing campaign log and load saved campaign log - findCampaignLog().destruct() + findUniqueObjectWithTag("CampaignLog").destruct() spawnObjectData({ data = importData["log"] }) - + chaosBagApi.setChaosBagState(importData["bag"]) -- populate trauma values @@ -145,24 +146,17 @@ function createCampaignFromToken(importData) playAreaApi.setInvestigatorCount(importData["clueCount"]) -- set campaign guide page - local guide = findCampaignGuide() + local guide = findUniqueObjectWithTag("CampaignGuide") if guide then Wait.condition( -- Called after the condition function returns true - function() - log("Campaign Guide import successful!") - end, + function() log("Campaign Guide import successful!") end, -- Condition function that is called continiously until returs true or timeout is reached - function() - guide.Book.setPage(importData["guide"]) - return guide.Book.getPage() == importData["guide"] - end, + function() return guide.Book.setPage(importData["guide"]) end, -- Amount of time in seconds until the Wait times out 1, -- Called if the Wait times out - function() - log("Campaign Guide import failed!") - end + function() log("Campaign Guide import failed!") end ) end @@ -183,26 +177,29 @@ function createCampaignToken(_, playerColor, _) blessCurseApi.removeAll(playerColor) chaosBagApi.releaseAllSealedTokens(playerColor) - local campaignBoxGUID = "" -- find active campaign + local campaignBox for _, obj in ipairs(getObjectsWithTag("CampaignBox")) do if obj.type == "Bag" and #obj.getObjects() == 0 then - if campaignBoxGUID ~= "" then + if not campaignBox then + campaignBox = obj + else broadcastToAll("Multiple empty campaign box detected; delete all but one.", Color.Red) return end - campaignBoxGUID = obj.getGUID() end end - if campaignBoxGUID == "" then + if not campaignBox then broadcastToAll("Campaign box with all placed objects not found!", Color.Red) return end - local campaignLog = findCampaignLog() + + local campaignLog = findUniqueObjectWithTag("CampaignLog") if campaignLog == nil then broadcastToAll("Campaign log not found!", Color.Red) return end + local traumaValues = { 0, 0, 0, 0, 0, 0, 0, 0 @@ -218,13 +215,15 @@ function createCampaignToken(_, playerColor, _) printToAll("Trauma values could not be found in campaign log!", "Yellow") printToAll("Default values for health and sanity loaded.", "Yellow") end - local campaignGuide = findCampaignGuide() + + local campaignGuide = findUniqueObjectWithTag("CampaignGuide") if campaignGuide == nil then broadcastToAll("Campaign guide not found!", Color.Red) return end + local campaignData = { - box = campaignBoxGUID, + box = campaignBox.getGUID(), log = campaignLog.getData(), bag = chaosBagApi.getChaosBagState(), trauma = traumaValues, @@ -235,7 +234,7 @@ function createCampaignToken(_, playerColor, _) playmat = playAreaApi.getSurface() } campaignTokenData.GMNotes = JSON.encode(campaignData) - campaignTokenData.Nickname = os.date("%b %d ") .. getObjectFromGUID(campaignBoxGUID).getName() .. " Save" + campaignTokenData.Nickname = os.date("%b %d ") .. campaignBox.getName() .. " Save" spawnObjectData({ data = campaignTokenData }) broadcastToAll("Campaign successfully exported! Save coin object to import on a fresh save", Color.Green) end @@ -244,30 +243,14 @@ end -- helper functions --------------------------------------------------------- -function findCampaignLog() - local campaignLog = getObjectsWithTag("CampaignLog") - if campaignLog then - if #campaignLog == 1 then - return campaignLog[1] - else - broadcastToAll("More than 1 campaign log detected; delete all but one.", Color.Red) - return nil - end - else - return nil - end -end +function findUniqueObjectWithTag(tag) + local objects = getObjectsWithTag(tag) + if not objects then return end -function findCampaignGuide() - local campaignGuide = getObjectsWithTag("CampaignGuide") - if campaignGuide then - if #campaignGuide == 1 then - return campaignGuide[1] - else - broadcastToAll("More than 1 campaign guide detected; delete all but one.", Color.Red) - return nil - end + if #objects == 1 then + return objects[1] else + broadcastToAll("More than 1 " .. tag .. " detected; delete all but one.", Color.Red) return nil end end diff --git a/src/arkhamdb/DeckImporterUi.ttslua b/src/arkhamdb/DeckImporterUi.ttslua index 10470d0e..892c087b 100644 --- a/src/arkhamdb/DeckImporterUi.ttslua +++ b/src/arkhamdb/DeckImporterUi.ttslua @@ -58,36 +58,9 @@ end -- loadNewest: True if the most upgraded version of the deck should be loaded -- investigators: True if investigator cards should be spawned function setUiState(uiStateTable) - -- Callback functions aren't triggered when editing buttons/inputs so values must be set manually - - if uiStateTable["greenDeck"] then - greenDeckId = uiStateTable["greenDeck"] - self.editInput({index=0, value=greenDeckId}) - end - if uiStateTable["redDeck"] then - redDeckId = uiStateTable["redDeck"] - self.editInput({index=1, value=redDeckId}) - end - if uiStateTable["whiteDeck"] then - whiteDeckId = uiStateTable["whiteDeck"] - self.editInput({index=2, value=whiteDeckId}) - end - if uiStateTable["orangeDeck"]then - orangeDeckId = uiStateTable["orangeDeck"] - self.editInput({index=3, value=orangeDeckId}) - end - if uiStateTable["private"] then - privateDeck = uiStateTable["private"] - self.editButton { index = 0, label = PRIVATE_TOGGLE_LABELS[privateDeck] } - end - if uiStateTable["loadNewest"] then - loadNewestDeck = uiStateTable["loadNewest"] - self.editButton { index = 1, label = UPGRADED_TOGGLE_LABELS[loadNewestDeck] } - end - if uiStateTable["investigators"] then - loadInvestigators = uiStateTable["investigators"] - self.editButton { index = 2, label = LOAD_INVESTIGATOR_TOGGLE_LABELS[loadInvestigators] } - end + self.clearButtons() + self.clearInputs() + initializeUi(uiStateTable) end -- Sets up the UI for the deck loader, populating fields from the given save state table decoded from onLoad() From 8c3e87867b5fc3ee26773d5b8f795c3cf40f3b5a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 1 Oct 2023 11:28:31 +0200 Subject: [PATCH 21/76] optimization --- config.json | 4 ++-- src/core/DoomInPlayCounter.ttslua | 2 +- src/core/Global.ttslua | 8 +++----- src/playermat/ClueCounter.ttslua | 3 +-- src/playermat/Playmat.ttslua | 7 ++----- src/playermat/PlaymatApi.ttslua | 9 ++------- 6 files changed, 11 insertions(+), 22 deletions(-) diff --git a/config.json b/config.json index f92d80ce..f50cdecb 100644 --- a/config.json +++ b/config.json @@ -131,11 +131,11 @@ "EdgeoftheEarth.895eaa", "TheDream-Eaters.a16a1a", "ReturntoTheCircleUndone.757324", - "Playermat4Red.0840d5", - "Playermat3Green.383d8b", "OtherDoominPlay.652ff3", "Playermat1White.8b081b", "Playermat2Orange.bd0ff4", + "Playermat3Green.383d8b", + "Playermat4Red.0840d5", "Neutral.2691e1", "Neutral.748245", "Neutral.271b17", diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index d3fa9a02..42f0c010 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -20,7 +20,7 @@ function onLoad() color = { 0, 0, 0, 0 } }) - trash = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" }) + TRASH = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" }) ZONE = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "PlayAreaZone" }) loopID = Wait.time(countDoom, 2, -1) end diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 92d13010..2b13285c 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -169,7 +169,7 @@ function getObjectFromMemo(searchParam) if matColor == nil or type == nil then return nil end for _, obj in ipairs(getObjects()) do local memo = obj.getMemo() - if memo then + if memo and memo:sub(1, 1) == "{" then local decoded = JSON.decode(memo) or {} if decoded.matColor == matColor and decoded.type == type then return obj @@ -184,10 +184,9 @@ end ---@return objList Table Table of type-object pairs function getObjectsForMatColor(matColor) local objList = {} - if matColor == nil then return objList end for _, obj in ipairs(getObjects()) do local memo = obj.getMemo() - if memo then + if memo and memo:sub(1, 1) == "{" then local decoded = JSON.decode(memo) or {} if decoded.matColor == matColor then objList[decoded.type] = obj @@ -202,10 +201,9 @@ end ---@return objList Table Table of matColor-object pairs 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 + if memo and memo:sub(1, 1) == "{" then local decoded = JSON.decode(memo) or {} if decoded.type == type then objList[decoded.matColor] = obj diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 9ea4069c..620f8637 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -52,8 +52,7 @@ function findValidItemsInSphere() direction = { 0, 1, 0 }, type = 2, max_distance = 0, - size = { 2, 2, 2 }, - --debug=true + size = { 2, 2, 2 } }) retval = {} diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 64137337..1f842a1a 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -903,14 +903,11 @@ end -- reports the clue count ---@param useClickableCounters Boolean Controls which type of counter is getting checked function getClueCount(useClickableCounters) - local count = 0 - if useClickableCounters then - count = tonumber(ownedObjects.ClickableClueCounter.getVar("val")) + return ownedObjects.ClickableClueCounter.getVar("val") else - count = tonumber(ownedObjects.ClueCounter.getVar("exposedValue")) + return ownedObjects.ClueCounter.getVar("exposedValue") end - return count end -- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index f7677177..f0d364f7 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -136,7 +136,7 @@ do PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 for _, mat in pairs(internal.getMatForColor(matColor)) do - count = count + tonumber(mat.call("getClueCount", useClickableCounters)) + count = count + mat.call("getClueCount", useClickableCounters) end return count end @@ -198,12 +198,7 @@ do ---@return array Table Single-element if only single playmat is requested internal.getMatForColor = function(matColor) if matColor == "All" then - return { - White = Global.call("getObjectFromMemo", {matColor = "White", type = "Playermat"}), - Orange = Global.call("getObjectFromMemo", {matColor = "Orange", type = "Playermat"}), - Green = Global.call("getObjectFromMemo", {matColor = "Green", type = "Playermat"}), - Red = Global.call("getObjectFromMemo", {matColor = "Red", type = "Playermat"}) - } + return Global.call("getObjectsForType", "Playermat") else return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) } end From da63663ef2185a42a2beb1c06deafe17fa20b22b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 01:36:49 +0200 Subject: [PATCH 22/76] optimization of loop functions --- objects/Playermat4Red.0840d5.json | 4 ++ src/core/DoomCounter.ttslua | 2 +- src/core/DoomInPlayCounter.ttslua | 66 ++++++++++++------------------- src/core/MasterClueCounter.ttslua | 3 +- src/playermat/Playmat.ttslua | 33 +++++++--------- src/playermat/PlaymatApi.ttslua | 8 +++- 6 files changed, 53 insertions(+), 63 deletions(-) diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index b02587ef..862ad7d1 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -351,6 +351,10 @@ "Nickname": "Playermat 4: Red", "Snap": true, "Sticky": true, + "Tags": [ + "Red", + "Playermat" + ], "Tooltip": false, "Transform": { "posX": -30.35, diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index dff220b4..5a930250 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -64,7 +64,7 @@ function startReset() if options.Agenda then updateVal(0) end - local DoomInPlayCounter = getObjectFromMemo({matColor = "Mythos", type = "DoomInPlayCounter"}) + local DoomInPlayCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomInPlayCounter"}) if DoomInPlayCounter then DoomInPlayCounter.call("removeDoom", options) end diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 42f0c010..c5dc0b6d 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -3,12 +3,21 @@ local playmatApi = require("playermat/PlaymatApi") local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" -local COLORS = { "White", "Orange", "Green", "Red" } +local TOTAL_PLAY_AREA = { + upperLeft = { + x = -10, + z = -35 + }, + lowerRight = { + x = -60, + z = 35 + } +} -- create button, context menu and start loop function onLoad() self.createButton({ - label = tostring(0), + label = "0", click_function = "none", function_owner = self, position = { 0, 0.06, 0 }, @@ -27,49 +36,21 @@ end -- main function function countDoom() - local objList = {} - - -- get doom objects in play area zone - for _, obj in ipairs(ZONE.getObjects()) do - if filterDoom(obj) then - table.insert(objList, obj) - end - end - - -- get doom objects on playmats - for i = 1, 4 do - local playmatList = playmatApi.searchAroundPlaymat(COLORS[i]) - for _, obj in ipairs(playmatList) do - if filterDoom(obj) then - table.insert(objList, obj) - end - end - end - - local doom = countDoomFromList(objList) - self.editButton({ index = 0, label = tostring(doom) }) -end - -function countDoomFromList(objList) local count = 0 - for _, obj in ipairs(objList) do + + -- get doom in play + for _, obj in ipairs(getObjects()) do count = count + getDoomAmount(obj) end - return count -end -function filterDoom(obj) - if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL) - or (obj.name == "Custom_Token" and obj.getCustomObject().image == doomURL) then - return true - else - return false - end + self.editButton({ index = 0, label = tostring(count) }) end -- gets quantity (for stacks) of doom function getDoomAmount(obj) - if not obj.hasTag(IGNORE_TAG) then + if (obj.is_face_down and obj.getCustomObject().image_bottom == doomURL) + and not obj.hasTag(IGNORE_TAG) + and inArea(obj.getPosition(), TOTAL_PLAY_AREA) then return math.abs(obj.getQuantity()) else return 0 @@ -81,9 +62,7 @@ function removeDoom(options) local count = 0 if options.Playermats then - for i = 1, 4 do - count = removeDoomFromList(playmatApi.searchAroundPlaymat(COLORS[i])) - end + count = removeDoomFromList(playmatApi.searchAroundPlaymat("All")) broadcastToAll(count .. " doom removed from Playermats.", "White") end @@ -105,3 +84,10 @@ function removeDoomFromList(objList) end return count end + +function inArea(point, bounds) + return (point.x < bounds.upperLeft.x + and point.x > bounds.lowerRight.x + and point.z > bounds.upperLeft.z + and point.z < bounds.lowerRight.z) +end diff --git a/src/core/MasterClueCounter.ttslua b/src/core/MasterClueCounter.ttslua index 29bdef48..426e3149 100644 --- a/src/core/MasterClueCounter.ttslua +++ b/src/core/MasterClueCounter.ttslua @@ -23,8 +23,7 @@ function onLoad(savedData) font_color = { 0, 0, 0, 100 }, color = { 0, 0, 0, 0 } }) - - loopID = Wait.time(sumClues, 2, -1) + Wait.time(sumClues, 2, -1) end -- removes all player clues by calling the respective function from the counting bowls / clickers diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 1f842a1a..dbe2ac63 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -148,9 +148,7 @@ function onLoad(saveState) end showDrawButton(isDrawButtonVisible) - collisionEnabled = true - math.randomseed(os.time()) end @@ -166,7 +164,7 @@ function searchArea(origin, size, filter) orientation = self.getRotation(), type = 3, size = size, - max_distance = 1 + max_distance = 0 }) local objList = {} @@ -188,6 +186,7 @@ function searchAroundSelf(filter) local bounds = self.getBoundsNormalized() -- Increase the width to cover the set aside zone bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER + bounds.size.y = 1 -- Since the cast is centered on the position, shift left or right to keep the non-set aside edge -- of the cast at the edge of the playmat -- setAsideDirection accounts for the set aside zone being on the left or right, depending on the @@ -618,17 +617,17 @@ function spawnTokensFor(object) tokenManager.spawnForCard(object, extraUses) end -function onCollisionEnter(collision_info) - local object = collision_info.collision_object - - -- detect if "Dream-Enhancing Serum" is placed - if object.getName() == "Dream-Enhancing Serum" then isDES = true end +function onCollisionEnter(collisionInfo) + local object = collisionInfo.collision_object -- only continue if loading is completed if not collisionEnabled then return end -- only continue for cards - if object.type ~= "Card" then return end + if not isCard(object) then return end + + -- detect if "Dream-Enhancing Serum" is placed + if object.getName() == "Dream-Enhancing Serum" then isDES = true end maybeUpdateActiveInvestigator(object) syncCustomizableMetadata(object) @@ -643,8 +642,8 @@ function onCollisionEnter(collision_info) end -- detect if "Dream-Enhancing Serum" is removed -function onCollisionExit(collision_info) - if collision_info.collision_object.getName() == "Dream-Enhancing Serum" then isDES = false end +function onCollisionExit(collisionInfo) + if collisionInfo.collision_object.getName() == "Dream-Enhancing Serum" then isDES = false end end -- checks if tokens should be spawned for the provided card @@ -680,14 +679,12 @@ function shouldSpawnTokens(card) end function onObjectEnterContainer(container, object) - Wait.frames(function() resetTokensIfInDeckZone(container, object) end, 1) -end + if not isCard(object) then return end -function resetTokensIfInDeckZone(container, object) - local pos = self.positionToLocal(container.getPosition()) - if inArea(pos, DECK_DISCARD_AREA) then + local localCardPos = self.positionToLocal(object.getPosition()) + if inArea(localCardPos, DECK_DISCARD_AREA) then tokenManager.resetTokensSpawned(object) - removeTokensFromObject(container) + removeTokensFromObject(object) end end @@ -702,7 +699,7 @@ function removeTokensFromObject(object) obj.getLock() == false and obj.getDescription() ~= "Action Token" and not tokenChecker.isChaosToken(obj) then - ownedObjects.TrashCan.putObject(obj) + ownedObjects.Trash.putObject(obj) end end end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index f0d364f7..21b524ca 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -170,12 +170,16 @@ do end -- finds all objects on the playmat and associated set aside zone and returns a table - ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param filter Function Optional filter function (return true for desired objects) PlaymatApi.searchAroundPlaymat = function(matColor, filter) + local objList = {} for _, mat in pairs(internal.getMatForColor(matColor)) do - return mat.call("searchAroundSelf", filter) + for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do + table.insert(objList, obj) + end end + return objList end -- Discard a non-hidden card from the corresponding player's hand From de61831956dc712192f6e2dc049556d884fd6d55 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 02:05:00 +0200 Subject: [PATCH 23/76] part of switching to tags --- .../CampaignImporterExporter.ttslua | 2 +- src/accessories/CleanUpHelper.ttslua | 14 ++-- src/accessories/TokenArrangerApi.ttslua | 2 +- src/arkhamdb/DeckImporterApi.ttslua | 4 +- src/chaosbag/BlessCurseManagerApi.ttslua | 2 +- src/core/DoomCounter.ttslua | 2 +- src/core/DoomInPlayCounter.ttslua | 4 +- src/core/GameKeyHandler.ttslua | 2 +- src/core/Global.ttslua | 39 +---------- src/core/MythosArea.ttslua | 9 +-- src/core/MythosAreaApi.ttslua | 4 +- src/core/NavigationOverlayApi.ttslua | 4 +- src/core/PlayArea.ttslua | 2 +- src/core/PlayAreaApi.ttslua | 6 +- src/core/SoundCubeApi.ttslua | 2 +- src/core/VictoryDisplay.ttslua | 6 +- src/core/VictoryDisplayApi.ttslua | 4 +- src/core/token/TokenManager.ttslua | 4 +- src/core/token/TokenSpawnTrackerApi.ttslua | 2 +- src/playercards/AllCardsBagApi.ttslua | 32 ++++----- src/playermat/ClueCounter.ttslua | 2 +- src/playermat/Playmat.ttslua | 9 ++- src/playermat/PlaymatApi.ttslua | 67 ++++++++++++------- 23 files changed, 104 insertions(+), 120 deletions(-) diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 8d6eeef2..65fbd108 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -163,7 +163,7 @@ function createCampaignFromToken(importData) Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5) -- destroy Tour Starter token - Global.call("getObjectFromMemo", { matColor = "Mythos", type = "TourStarter" }).destruct() + getObjectsWithTag("TourStarter")[1].destruct() -- restore PlayArea image playAreaApi.updateSurface(importData["playmat"]) diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 8523a6f7..c82339c5 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -143,7 +143,7 @@ end -- reset doom on agenda function resetDoomCounter() - local doomCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomCounter"}) + local doomCounter = getObjectsWithTag("DoomCounter")[1] if doomCounter ~= nil then doomCounter.call("updateVal") else @@ -228,7 +228,7 @@ end function discardHands() if not options["tidyPlayermats"] then return end for i = 1, 4 do - local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"}) + local trash = getObjectsWithAllTags({COLORS[i], "Trash"}) if trash == nil then return end local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects() for j = #hand, 1, -1 do @@ -239,8 +239,8 @@ end -- clean up for play area function tidyPlayareaCoroutine() - local trash = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) - local playAreaZone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"}) + local trash = getObjectsWithAllTags({"Mythos", "Trash"}) + local playAreaZone = getObjectsWithTag("PlayAreaZone")[1] if playAreaZone == nil then printToAll("Scripting zone for main play area could not be found!", "Red") @@ -270,7 +270,7 @@ function tidyPlayerMatCoroutine() for k = 1, 30 do coroutine.yield(0) end -- get respective trash - local trash = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Trash"}) + local trash = getObjectsWithAllTags({COLORS[i], "Trash"}) if trash == nil then printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red") return 1 @@ -300,7 +300,7 @@ function tidyPlayerMatCoroutine() -- reset "activeInvestigatorId" if i < 5 then - local playermat = Global.call("getObjectFromMemo", {matColor = COLORS[i], type = "Playermat"}) + local playermat = getObjectsWithAllTags({COLORS[i], "Playermat"}) if playermat then playermat.setVar("activeInvestigatorId", "00000") end @@ -308,7 +308,7 @@ function tidyPlayerMatCoroutine() end end - local datahelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"}) + local datahelper = getObjectsWithTag("DataHelper")[1] if datahelper then datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {}) end diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index aa02d0ce..47afb77f 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -5,7 +5,7 @@ do ---@param functionName String Name of the function to cal ---@param argument Variant Parameter to pass local function callIfExistent(functionName, argument) - local tokenArranger = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenArranger"}) + local tokenArranger = getObjectsWithTag("TokenArranger")[1] if tokenArranger ~= nil then tokenArranger.call(functionName, argument) end diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 8bab141a..13e6202b 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -13,7 +13,7 @@ do -- investigators: True if investigator cards should be spawned DeckImporterApi.getUiState = function() local passthroughTable = {} - local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"}) + local DeckImporter = getObjectsWithTag("DeckImporter")[1] for k,v in pairs(DeckImporter.call("getUiState")) do passthroughTable[k] = v end @@ -31,7 +31,7 @@ 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) - local DeckImporter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DeckImporter"}) + local DeckImporter = getObjectsWithTag("DeckImporter")[1] return DeckImporter.call("setUiState", uiStateTable) end diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index 639fe7d8..0a97644d 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -3,7 +3,7 @@ do local internal = {} internal.getManager = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "BlessCurseManager"}) + return getObjectsWithTag("BlessCurseManager")[1] end -- removes all taken tokens and resets the counts diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index 5a930250..aa133b09 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -64,7 +64,7 @@ function startReset() if options.Agenda then updateVal(0) end - local DoomInPlayCounter = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DoomInPlayCounter"}) + local DoomInPlayCounter = getObjectsWithTag("DoomInPlayCounter")[1] if DoomInPlayCounter then DoomInPlayCounter.call("removeDoom", options) end diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index c5dc0b6d..0d86b260 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -29,8 +29,8 @@ function onLoad() color = { 0, 0, 0, 0 } }) - TRASH = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" }) - ZONE = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "PlayAreaZone" }) + TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) + ZONE = getObjectsWithAllTags({"Mythos", "PlayAreaZone" }) loopID = Wait.time(countDoom, 2, -1) end diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 70ff89f8..4d6043c4 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -41,7 +41,7 @@ end -- adds 1 doom to the agenda function addDoomToAgenda() - getObjectFromMemo({matColor = "Mythos", type = "DoomCounter"}).call("addVal", 1) + getObjectsWithTag("DoomCounter")[1].call("addVal", 1) end -- moves the hovered card to the victory display diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 2b13285c..1863657c 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -127,7 +127,7 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - DATA_HELPER = getObjectFromMemo({matColor = "Mythos", type = "DataHelper"}) + DATA_HELPER = getObjectsWithTag("DataHelper")[1] resetChaosTokenStatTracker() getModVersion() math.randomseed(os.time()) @@ -161,24 +161,6 @@ 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 and memo:sub(1, 1) == "{" 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 ---@return objList Table Table of type-object pairs @@ -196,23 +178,6 @@ function getObjectsForMatColor(matColor) return objList end --- gets all objects that match the provided type, sorted by owner ----@param type String Object to look for (usually name without spaces) ----@return objList Table Table of matColor-object pairs -function getObjectsForType(type) - local objList = {} - for _, obj in ipairs(getObjects()) do - local memo = obj.getMemo() - if memo and memo:sub(1, 1) == "{" then - local decoded = JSON.decode(memo) or {} - if decoded.type == type then - objList[decoded.matColor] = obj - end - end - end - return objList -end - --------------------------------------------------------- -- chaos token drawing --------------------------------------------------------- @@ -992,7 +957,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 = getObjectFromMemo({matColor = "Mythos", type = "OptionPanelSource"}) + local sourceBag = getObjectsWithTag("OptionPanelSource")[1] -- error handling for missing sourceBag if not sourceBag then diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 3391e54f..4b35372b 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -20,7 +20,8 @@ local isReshuffling = false -- scenario metadata local currentScenario, useFrontData, tokenData -local TRASHCAN, DATA_HELPER +-- object references +local TRASH, DATA_HELPER -- we use this to turn off collision handling until onLoad() is complete local collisionEnabled = false @@ -32,8 +33,8 @@ function onLoad(saveState) useFrontData = loadedState.useFrontData or true tokenData = loadedState.tokenData or {} end - TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) - DATA_HELPER = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"}) + TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) + DATA_HELPER = getObjectsWithTag("DataHelper")[1] collisionEnabled = true end @@ -206,7 +207,7 @@ function removeTokensFromObject(object) obj.memo ~= nil and obj.getLock() == false and not tokenChecker.isChaosToken(obj) then - TRASHCAN.putObject(obj) + TRASH.putObject(obj) end end end diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index c7b406d9..4f08509e 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -3,13 +3,13 @@ do -- returns the chaos token metadata (if provided through scenario reference card) MythosAreaApi.returnTokenData = function() - local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"}) + local MythosArea = getObjectsWithTag("MythosArea")[1] return MythosArea.call("returnTokenData") end -- draw an encounter card to the requested position/rotation MythosAreaApi.drawEncounterCard = function(pos, rotY, alwaysFaceUp) - local MythosArea = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "MythosArea"}) + local MythosArea = getObjectsWithTag("MythosArea")[1] MythosArea.call("drawEncounterCard", { pos = pos, rotY = rotY, diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index 865da421..b1e92dd5 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -5,7 +5,7 @@ do ---@param startColor String Color of the player to copy from ---@param targetColor String Color of the targeted player NavigationOverlayApi.copyVisibility = function(startColor, targetColor) - local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"}) + local handler = getObjectsWithTag("NavigationOverlayHandler")[1] handler.call("copyVisibility", { startColor = startColor, targetColor = targetColor @@ -15,7 +15,7 @@ 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) - local handler = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "NavigationOverlayHandler"}) + local handler = getObjectsWithTag("NavigationOverlayHandler")[1] handler.call("cycleVisibility", playerColor) end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 0dee301c..e80cffd1 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -506,7 +506,7 @@ function shiftContentsRight(playerColor) end function shiftContents(playerColor, direction) - local zone = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayAreaZone"}) + local zone = getObjectsWithTag("PlayAreaZone")[1] if not zone then broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") return diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 7be3c6a4..66dad51c 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -3,19 +3,19 @@ do local internal = {} internal.getPlayArea = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "PlayArea"}) + return getObjectsWithTag("PlayArea")[1] end -- 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 Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).getVar("val") + return getObjectsWithTag("InvestigatorCounter")[1].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 Global.call("getObjectFromMemo", {matColor = "Mythos", type = "InvestigatorCounter"}).call("updateVal", count) + return getObjectsWithTag("InvestigatorCounter")[1].call("updateVal", count) end -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 18a18bf5..13d11fa3 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -9,7 +9,7 @@ do } local function playTriggerEffect(index) - local SoundCube = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "SoundCube"}) + local SoundCube = getObjectsWithTag("SoundCube")[1] SoundCube.AssetBundle.playTriggerEffect(index) end diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index 0d642ce2..f706ba63 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -10,11 +10,11 @@ local countedVP = {} local highlightMissing = false local highlightCounted = false -local TRASHCAN +local TRASH -- button creation when loading the game function onLoad() - TRASHCAN = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "Trash"}) + TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) -- index 0: VP - "Display" local buttonParameters = {} @@ -282,7 +282,7 @@ function placeCard(card) local chaosBag = chaosBagApi.findChaosBag() chaosBag.putObject(obj) elseif obj.memo ~= nil and obj.getLock() == false then - TRASHCAN.putObject(obj) + TRASH.putObject(obj) end end diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index 4ba047f1..6dc0fad4 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -4,7 +4,7 @@ do -- triggers an update of the Victory count ---@param delay Number Delay in seconds after which the update call is executed VictoryDisplayApi.update = function(delay) - local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"}) + local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1] VictoryDisplay.call("startUpdate", delay) end @@ -12,7 +12,7 @@ do ---@param object Object Object that should be checked and potentially moved VictoryDisplayApi.placeCard = function(object) if object ~= nil and object.tag == "Card" then - local VictoryDisplay = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "VictoryDisplay"}) + local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1] VictoryDisplay.call("placeCard", object) end end diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 95386196..bd4972ea 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -335,7 +335,7 @@ do return end tokenTemplates = { } - local tokenSource = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSource"}) + local tokenSource = getObjectsWithTag("TokenSource")[1] for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do local tokenName = tokenTemplate.Memo tokenTemplates[tokenName] = tokenTemplate @@ -347,7 +347,7 @@ do if playerCardData ~= nil then return end - local dataHelper = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "DataHelper"}) + local dataHelper = getObjectsWithTag("DataHelper")[1] playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA') end diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index c8f8407d..21eaf9da 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -3,7 +3,7 @@ do local internal = {} internal.getSpawnTracker = function() - return Global.call("getObjectFromMemo", {matColor = "Mythos", type = "TokenSpawnTracker"}) + return getObjectsWithTag("TokenSpawnTracker")[1] end TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 76216d81..322b2aad 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -1,5 +1,10 @@ do local AllCardsBagApi = {} + local internal = {} + + internal.getAllCardsBag = function() + return getObjectsWithTag("AllCardsBag")[1] + end -- Returns a specific card from the bag, based on ArkhamDB ID ---@param id table String ID of the card to retrieve @@ -9,8 +14,7 @@ do -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata AllCardsBagApi.getCardById = function(id) - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getCardById", {id = id}) + internal.getAllCardsBag().call("getCardById", {id = id}) end -- Gets a random basic weakness from the bag. Once a given ID has been returned @@ -19,13 +23,11 @@ do -- weaknesses. ---@return id String ID of the selected weakness. AllCardsBagApi.getRandomWeaknessId = function() - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getRandomWeaknessId") + internal.getAllCardsBag().call("getRandomWeaknessId") end AllCardsBagApi.isIndexReady = function() - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("isIndexReady") + internal.getAllCardsBag().call("isIndexReady") end -- Called by Hotfix bags when they load. If we are still loading indexes, then @@ -34,8 +36,7 @@ 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() - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("rebuildIndexForHotfix") + internal.getAllCardsBag().call("rebuildIndexForHotfix") end -- Searches the bag for cards which match the given name and returns a list. Note that this is @@ -43,13 +44,11 @@ do ---@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) - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getCardsByName", {name = name, exact = exact}) + internal.getAllCardsBag().call("getCardsByName", {name = name, exact = exact}) end AllCardsBagApi.isBagPresent = function() - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag and true + internal.getAllCardsBag() and true end -- Returns a list of cards from the bag matching a class and level (0 or upgraded) @@ -60,18 +59,15 @@ do -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded) - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getCardsByClassAndLevel", {class = class, upgraded = upgraded}) + internal.getAllCardsBag().call("getCardsByClassAndLevel", {class = class, upgraded = upgraded}) end AllCardsBagApi.getCardsByCycle = function(cycle) - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getCardsByCycle", cycle) + internal.getAllCardsBag().call("getCardsByCycle", cycle) end AllCardsBagApi.getUniqueWeaknesses = function() - local AllCardsBag = Global.call("getObjectFromMemo", {matColor = "Mythos", type = "AllCardsBag"}) - return AllCardsBag.call("getUniqueWeaknesses") + internal.getAllCardsBag().call("getUniqueWeaknesses") end return AllCardsBagApi diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 620f8637..45985fde 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -23,7 +23,7 @@ function onLoad() }) -- set MATCOLOR based on memo MATCOLOR = JSON.decode(self.getMemo()).matColor - TRASH = Global.call("getObjectFromMemo", {matColor = MATCOLOR, type = "Trash"}) + TRASH = getObjectsWithAllTags({MATCOLOR, "Trash"}) loopID = Wait.time(countItems, 1, -1) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index dbe2ac63..dc5858a9 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -103,7 +103,7 @@ function onLoad(saveState) self.interactable = DEBUG -- get object references to owned objects - ownedObjects = Global.call("getObjectsForMatColor", matColor) + getOwnedObjects() -- button creation for i = 1, 6 do @@ -152,6 +152,13 @@ function onLoad(saveState) math.randomseed(os.time()) end +function getOwnedObjects() + local objList = getObjectsWithTag(matColor) + for _, obj in ipairs(objList) do + + end +end + --------------------------------------------------------- -- utility functions --------------------------------------------------------- diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 21b524ca..2250bbe0 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -6,11 +6,18 @@ do ---@param startPos Table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) local result, smallestDistance - for matColor, mat in pairs(internal.getMatForColor("All")) do + for _, mat in ipairs(internal.getMatForColor("All")) do local distance = Vector.between(startPos, mat.getPosition()):magnitude() if smallestDistance == nil or distance < smallestDistance then smallestDistance = distance - result = matColor + for _, tag in ipairs(mat.getTags) do + if tag == "White" + or tag == "Orange" + or tag == "Green" + or tag == "Red" then + result = tag + end + end end end return result @@ -19,7 +26,7 @@ do -- Returns the color of the player's hand that is seated next to the playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getPlayerColor = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.getVar("playerColor") end end @@ -27,17 +34,25 @@ do -- Returns the color of the playmat that owns the playercolor's hand ---@param handColor String Color of the playmat PlaymatApi.getMatColor = function(handColor) - for matColor, mat in pairs(internal.getMatForColor("All")) do + for _, mat in ipairs(internal.getMatForColor("All")) do local playerColor = mat.getVar("playerColor") - if playerColor == handColor then return matColor end + if playerColor == handColor then + for _, tag in ipairs(mat.getTags) do + if tag == "White" + or tag == "Orange" + or tag == "Green" + or tag == "Red" then + return tag + end + end + end end - return "NOT_FOUND" end -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.getVar("isDES") end end @@ -45,7 +60,7 @@ do -- Returns the draw deck of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDrawDeck = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end @@ -54,7 +69,7 @@ do -- Returns the position of the discard pile of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.call("returnGlobalDiscardPosition") end end @@ -63,7 +78,7 @@ do ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.positionToWorld(localPos) end end @@ -71,7 +86,7 @@ do -- Returns the rotation of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.getRotation() end end @@ -80,7 +95,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("doUpkeepFromHotkey", playerColor) end end @@ -88,7 +103,7 @@ do -- Returns the active investigator id ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.getVar("activeInvestigatorId") end end @@ -100,7 +115,7 @@ do ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end @@ -109,7 +124,7 @@ do ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end @@ -118,7 +133,7 @@ do ---@param showCounter Boolean Whether the clickable counter should be present or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end @@ -126,7 +141,7 @@ do -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("removeClues") end end @@ -135,7 +150,7 @@ do ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do count = count + mat.call("getClueCount", useClickableCounters) end return count @@ -147,7 +162,7 @@ do ---@param newValue Number Value to set the counter to ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier}) end end @@ -156,7 +171,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") ---@param type String Counter to target PlaymatApi.getCounterValue = function(matColor, type) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do return mat.call("getCounterValue", type) end end @@ -164,7 +179,7 @@ do -- resets the specified skill tracker to "1, 1, 1, 1" ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("resetSkillTracker") end end @@ -174,7 +189,7 @@ do ---@param filter Function Optional filter function (return true for desired objects) PlaymatApi.searchAroundPlaymat = function(matColor, filter) local objList = {} - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do table.insert(objList, obj) end @@ -185,14 +200,14 @@ do -- Discard a non-hidden card from the corresponding player's hand ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("doDiscardOne") end end -- Triggers the metadata sync for all playmats PlaymatApi.syncAllCustomizableCards = function() - for _, mat in pairs(internal.getMatForColor("All")) do + for _, mat in ipairs(internal.getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end @@ -202,9 +217,9 @@ do ---@return array Table Single-element if only single playmat is requested internal.getMatForColor = function(matColor) if matColor == "All" then - return Global.call("getObjectsForType", "Playermat") + return getObjectsWithTag("Playermat") else - return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) } + return {matColor = getObjectsWithAllTags({matColor, "Playermat"}) } end end From ce01733ef358aa5f38de813d139ff1378e0bc952 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 13:51:10 +0200 Subject: [PATCH 24/76] added guid reference handler --- config.json | 1 + objects/AllPlayerCards.15bb07.json | 1 - objects/ArkhamDBDeckImporter.a28140.json | 1 - objects/BlessCurseManager.5933fb.json | 1 - objects/ClueCounter.032300.json | 1 - objects/ClueCounter.1769ed.json | 1 - objects/ClueCounter.37be78.json | 1 - objects/ClueCounter.d86b7c.json | 1 - objects/Clues.3f22e5.json | 1 - objects/Clues.4111de.json | 1 - objects/Clues.891403.json | 1 - objects/Clues.db85d6.json | 1 - objects/Damage.1f5a0a.json | 1 - objects/Damage.591a45.json | 1 - objects/Damage.e64eec.json | 1 - objects/Damage.eb08d6.json | 1 - objects/DataHelper.708279.json | 1 - objects/DoomCounter.85c4c6.json | 1 - objects/GUIDReferenceHandler.da23e4.json | 48 +++++++++ objects/HandTrigger.0285cc.json | 1 - objects/HandTrigger.5fe087.json | 1 - objects/HandTrigger.a70eee.json | 1 - objects/HandTrigger.be2f17.json | 1 - objects/Horror.0257d9.json | 1 - objects/Horror.468e88.json | 1 - objects/Horror.7b5729.json | 1 - objects/Horror.beb964.json | 1 - objects/InvestigatorCount.f182ee.json | 1 - objects/InvestigatorSkillTracker.af7ed7.json | 1 - objects/InvestigatorSkillTracker.b4a5f7.json | 1 - objects/InvestigatorSkillTracker.e598c2.json | 1 - objects/InvestigatorSkillTracker.e74881.json | 1 - objects/MasterClueCounter.4a3aa4.json | 1 - objects/MythosArea.9f334f.json | 1 - objects/NavigationOverlayHandler.797ede.json | 1 - objects/OptionPanelSource.830bd0.json | 1 - objects/OtherDoominPlay.652ff3.json | 1 - objects/Playarea.721ba2.json | 1 - objects/PlayerCards.2d30ee.json | 1 - objects/Playermat1White.8b081b.json | 2 +- objects/Playermat2Orange.bd0ff4.json | 2 +- objects/Playermat3Green.383d8b.json | 2 +- objects/Playermat4Red.0840d5.json | 2 +- objects/Resources.4406f0.json | 1 - objects/Resources.816d84.json | 1 - objects/Resources.a4b60d.json | 1 - objects/Resources.cd15ac.json | 1 - objects/Resourcetokens.9fadf9.json | 1 - objects/RulesReference.d99993.json | 1 - objects/SCEDTour.0e5aa8.json | 1 - objects/ScriptingTrigger.a2f932.json | 1 - objects/SoundCube.3c988f.json | 1 - objects/ThePathtoCarcosa.aca04c.json | 1 - objects/TokenArranger.022907.json | 1 - objects/TokenSource.124381.json | 1 - objects/TokenSpawnTracker.e3ffc9.json | 1 - objects/Trash.147e80.json | 1 - objects/Trash.4b8594.json | 1 - objects/Trash.5f896a.json | 1 - objects/Trash.70b9f6.json | 1 - objects/Trash.f7b6c8.json | 1 - objects/VictoryDisplay.6ccd6d.json | 1 - .../CampaignImporterExporter.ttslua | 5 +- src/accessories/CleanUpHelper.ttslua | 16 +-- src/accessories/TokenArrangerApi.ttslua | 3 +- src/arkhamdb/DeckImporterApi.ttslua | 5 +- src/chaosbag/BlessCurseManagerApi.ttslua | 18 ++-- src/core/DoomCounter.ttslua | 3 +- src/core/DoomInPlayCounter.ttslua | 6 +- src/core/GUIDReferenceHandler.ttslua | 99 +++++++++++++++++++ src/core/GameKeyHandler.ttslua | 5 +- src/core/Global.ttslua | 6 +- src/core/MythosArea.ttslua | 6 +- src/core/MythosAreaApi.ttslua | 11 ++- src/core/NavigationOverlayApi.ttslua | 11 ++- src/core/PlayArea.ttslua | 4 +- src/core/PlayAreaApi.ttslua | 46 +++++---- src/core/SoundCubeApi.ttslua | 3 +- src/core/VictoryDisplay.ttslua | 9 +- src/core/VictoryDisplayApi.ttslua | 11 ++- src/core/token/TokenManager.ttslua | 6 +- src/core/token/TokenSpawnTrackerApi.ttslua | 18 ++-- src/playercards/AllCardsBagApi.ttslua | 24 ++--- src/playermat/ClueCounter.ttslua | 26 +---- src/playermat/Playmat.ttslua | 17 ++-- src/playermat/PlaymatApi.ttslua | 7 +- 86 files changed, 292 insertions(+), 186 deletions(-) create mode 100644 objects/GUIDReferenceHandler.da23e4.json create mode 100644 src/core/GUIDReferenceHandler.ttslua diff --git a/config.json b/config.json index f50cdecb..f688047f 100644 --- a/config.json +++ b/config.json @@ -19,6 +19,7 @@ "MusicPlayer_path": "MusicPlayer.json", "Note": "", "ObjectStates_order": [ + "GUIDReferenceHandler.da23e4", "HandTrigger.5fe087", "HandTrigger.be2f17", "HandTrigger.0285cc", diff --git a/objects/AllPlayerCards.15bb07.json b/objects/AllPlayerCards.15bb07.json index af75a7b5..f0715db7 100644 --- a/objects/AllPlayerCards.15bb07.json +++ b/objects/AllPlayerCards.15bb07.json @@ -1575,7 +1575,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"AllCardsBag\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "All Player Cards", diff --git a/objects/ArkhamDBDeckImporter.a28140.json b/objects/ArkhamDBDeckImporter.a28140.json index 8a42ae1a..418d63a3 100644 --- a/objects/ArkhamDBDeckImporter.a28140.json +++ b/objects/ArkhamDBDeckImporter.a28140.json @@ -36,7 +36,6 @@ "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, diff --git a/objects/BlessCurseManager.5933fb.json b/objects/BlessCurseManager.5933fb.json index c7325804..ae7809ce 100644 --- a/objects/BlessCurseManager.5933fb.json +++ b/objects/BlessCurseManager.5933fb.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"chaosbag/BlessCurseManager\")", "LuaScriptState": "false", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"BlessCurseManager\"}", "Name": "Custom_Token", "Nickname": "Bless/Curse Manager", "Snap": true, diff --git a/objects/ClueCounter.032300.json b/objects/ClueCounter.032300.json index b3453154..71211083 100644 --- a/objects/ClueCounter.032300.json +++ b/objects/ClueCounter.032300.json @@ -45,7 +45,6 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.1769ed.json b/objects/ClueCounter.1769ed.json index ef8f9040..914b6298 100644 --- a/objects/ClueCounter.1769ed.json +++ b/objects/ClueCounter.1769ed.json @@ -45,7 +45,6 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.37be78.json b/objects/ClueCounter.37be78.json index d43058e5..5b7fcb52 100644 --- a/objects/ClueCounter.37be78.json +++ b/objects/ClueCounter.37be78.json @@ -45,7 +45,6 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/ClueCounter.d86b7c.json b/objects/ClueCounter.d86b7c.json index ce05c108..8beb0fc8 100644 --- a/objects/ClueCounter.d86b7c.json +++ b/objects/ClueCounter.d86b7c.json @@ -45,7 +45,6 @@ "LuaScript": "require(\"playermat/ClueCounter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"ClueCounter\"}", "Name": "Custom_Model", "Nickname": "Clue Counter", "Snap": true, diff --git a/objects/Clues.3f22e5.json b/objects/Clues.3f22e5.json index 18ea7e44..17a50489 100644 --- a/objects/Clues.3f22e5.json +++ b/objects/Clues.3f22e5.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.4111de.json b/objects/Clues.4111de.json index 01eac58b..97c69558 100644 --- a/objects/Clues.4111de.json +++ b/objects/Clues.4111de.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.891403.json b/objects/Clues.891403.json index 64b11f2e..32174201 100644 --- a/objects/Clues.891403.json +++ b/objects/Clues.891403.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Clues.db85d6.json b/objects/Clues.db85d6.json index 2a9177df..902a38f5 100644 --- a/objects/Clues.db85d6.json +++ b/objects/Clues.db85d6.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"ClickableClueCounter\"}", "Name": "Custom_Token", "Nickname": "Clues", "Snap": true, diff --git a/objects/Damage.1f5a0a.json b/objects/Damage.1f5a0a.json index 3e21c9ac..38534af1 100644 --- a/objects/Damage.1f5a0a.json +++ b/objects/Damage.1f5a0a.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.591a45.json b/objects/Damage.591a45.json index b8f9f6b4..b1c402b9 100644 --- a/objects/Damage.591a45.json +++ b/objects/Damage.591a45.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.e64eec.json b/objects/Damage.e64eec.json index e82254b7..99f89b60 100644 --- a/objects/Damage.e64eec.json +++ b/objects/Damage.e64eec.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/Damage.eb08d6.json b/objects/Damage.eb08d6.json index f4a3ea15..39eab22d 100644 --- a/objects/Damage.eb08d6.json +++ b/objects/Damage.eb08d6.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"DamageCounter\"}", "Name": "Custom_Token", "Nickname": "Damage\n", "Snap": true, diff --git a/objects/DataHelper.708279.json b/objects/DataHelper.708279.json index 78a32f2e..1e3696b0 100644 --- a/objects/DataHelper.708279.json +++ b/objects/DataHelper.708279.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/DataHelper\")", "LuaScriptState": "[]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DataHelper\"}", "Name": "Custom_Tile", "Nickname": "Data Helper", "Snap": true, diff --git a/objects/DoomCounter.85c4c6.json b/objects/DoomCounter.85c4c6.json index c5d41256..6f061c53 100644 --- a/objects/DoomCounter.85c4c6.json +++ b/objects/DoomCounter.85c4c6.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/DoomCounter\")", "LuaScriptState": "[0,{\"Agenda\":true,\"Playarea\":true,\"Playermats\":true}]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DoomCounter\"}", "Name": "Custom_Token", "Nickname": "Doom Counter", "Snap": true, diff --git a/objects/GUIDReferenceHandler.da23e4.json b/objects/GUIDReferenceHandler.da23e4.json new file mode 100644 index 00000000..4f868304 --- /dev/null +++ b/objects/GUIDReferenceHandler.da23e4.json @@ -0,0 +1,48 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.116, + "g": 0.116, + "r": 0.716 + }, + "Description": "This object handles GUID references to objects.", + "DragSelectable": true, + "GMNotes": "", + "GUID": "da23e4", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "require(\"core/GUIDReferenceHandler\")", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "go_game_piece_white", + "Nickname": "GUID Reference Handler", + "Snap": true, + "Sticky": true, + "Tags": [ + "GUIDs" + ], + "Tooltip": true, + "Transform": { + "posX": 78, + "posY": 1.328, + "posZ": -8, + "rotX": 0, + "rotY": 0, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/objects/HandTrigger.0285cc.json b/objects/HandTrigger.0285cc.json index 735a2aa8..d8eff7f5 100644 --- a/objects/HandTrigger.0285cc.json +++ b/objects/HandTrigger.0285cc.json @@ -26,7 +26,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.5fe087.json b/objects/HandTrigger.5fe087.json index b4867966..0ea988e6 100644 --- a/objects/HandTrigger.5fe087.json +++ b/objects/HandTrigger.5fe087.json @@ -26,7 +26,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.a70eee.json b/objects/HandTrigger.a70eee.json index d4713ce7..9fcb112a 100644 --- a/objects/HandTrigger.a70eee.json +++ b/objects/HandTrigger.a70eee.json @@ -26,7 +26,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/HandTrigger.be2f17.json b/objects/HandTrigger.be2f17.json index 19dbb68d..ac40365c 100644 --- a/objects/HandTrigger.be2f17.json +++ b/objects/HandTrigger.be2f17.json @@ -26,7 +26,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"HandZone\"}", "Name": "HandTrigger", "Nickname": "", "Snap": true, diff --git a/objects/Horror.0257d9.json b/objects/Horror.0257d9.json index 5be90941..f933c101 100644 --- a/objects/Horror.0257d9.json +++ b/objects/Horror.0257d9.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.468e88.json b/objects/Horror.468e88.json index 620826ca..b6a6cb0b 100644 --- a/objects/Horror.468e88.json +++ b/objects/Horror.468e88.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.7b5729.json b/objects/Horror.7b5729.json index c8214fa4..973828d6 100644 --- a/objects/Horror.7b5729.json +++ b/objects/Horror.7b5729.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/Horror.beb964.json b/objects/Horror.beb964.json index 77c029f6..9564ddac 100644 --- a/objects/Horror.beb964.json +++ b/objects/Horror.beb964.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "0", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"HorrorCounter\"}", "Name": "Custom_Token", "Nickname": "Horror", "Snap": true, diff --git a/objects/InvestigatorCount.f182ee.json b/objects/InvestigatorCount.f182ee.json index 8566a1aa..3229f06b 100644 --- a/objects/InvestigatorCount.f182ee.json +++ b/objects/InvestigatorCount.f182ee.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/ActiveInvestigatorCounter\")", "LuaScriptState": "2", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"InvestigatorCounter\"}", "Name": "Custom_Token", "Nickname": "Investigator Count", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.af7ed7.json b/objects/InvestigatorSkillTracker.af7ed7.json index ed05ca40..8e320a3d 100644 --- a/objects/InvestigatorSkillTracker.af7ed7.json +++ b/objects/InvestigatorSkillTracker.af7ed7.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.b4a5f7.json b/objects/InvestigatorSkillTracker.b4a5f7.json index dd711c4f..cbf2123d 100644 --- a/objects/InvestigatorSkillTracker.b4a5f7.json +++ b/objects/InvestigatorSkillTracker.b4a5f7.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.e598c2.json b/objects/InvestigatorSkillTracker.e598c2.json index 91a44681..c82d17bf 100644 --- a/objects/InvestigatorSkillTracker.e598c2.json +++ b/objects/InvestigatorSkillTracker.e598c2.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/InvestigatorSkillTracker.e74881.json b/objects/InvestigatorSkillTracker.e74881.json index 5d5a57b5..aad443c7 100644 --- a/objects/InvestigatorSkillTracker.e74881.json +++ b/objects/InvestigatorSkillTracker.e74881.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"playermat/InvestigatorSkillTracker\")", "LuaScriptState": "[1,1,1,1]", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"InvestigatorSkillTracker\"}", "Name": "Custom_Token", "Nickname": "Investigator Skill Tracker", "Snap": true, diff --git a/objects/MasterClueCounter.4a3aa4.json b/objects/MasterClueCounter.4a3aa4.json index f5612158..69d25c0f 100644 --- a/objects/MasterClueCounter.4a3aa4.json +++ b/objects/MasterClueCounter.4a3aa4.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/MasterClueCounter\")", "LuaScriptState": "false", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"MasterClueCounter\"}", "Name": "Custom_Token", "Nickname": "Master Clue Counter", "Snap": true, diff --git a/objects/MythosArea.9f334f.json b/objects/MythosArea.9f334f.json index 24b7fa4b..1eeead24 100644 --- a/objects/MythosArea.9f334f.json +++ b/objects/MythosArea.9f334f.json @@ -62,7 +62,6 @@ "LuaScript": "require(\"core/MythosArea\")", "LuaScriptState": "{\"currentScenario\":\"\",\"tokenData\":[],\"useFrontData\":true}", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"MythosArea\"}", "Name": "Custom_Tile", "Nickname": "Mythos Area", "Snap": true, diff --git a/objects/NavigationOverlayHandler.797ede.json b/objects/NavigationOverlayHandler.797ede.json index 16a9c51f..7b15773a 100644 --- a/objects/NavigationOverlayHandler.797ede.json +++ b/objects/NavigationOverlayHandler.797ede.json @@ -24,7 +24,6 @@ "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, diff --git a/objects/OptionPanelSource.830bd0.json b/objects/OptionPanelSource.830bd0.json index 9b7d96ce..98907beb 100644 --- a/objects/OptionPanelSource.830bd0.json +++ b/objects/OptionPanelSource.830bd0.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"OptionPanelSource\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "OptionPanel Source", diff --git a/objects/OtherDoominPlay.652ff3.json b/objects/OtherDoominPlay.652ff3.json index 3bde1d78..6150163c 100644 --- a/objects/OtherDoominPlay.652ff3.json +++ b/objects/OtherDoominPlay.652ff3.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/DoomInPlayCounter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"DoomInPlayCounter\"}", "Name": "Custom_Token", "Nickname": "Other Doom in Play", "Snap": true, diff --git a/objects/Playarea.721ba2.json b/objects/Playarea.721ba2.json index 8057603a..b820bf54 100644 --- a/objects/Playarea.721ba2.json +++ b/objects/Playarea.721ba2.json @@ -973,7 +973,6 @@ "LuaScript": "require(\"core/PlayArea\")", "LuaScriptState": "{\"trackedLocations\":[]}", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayArea\"}", "Name": "Custom_Token", "Nickname": "Play Area", "Snap": true, diff --git a/objects/PlayerCards.2d30ee.json b/objects/PlayerCards.2d30ee.json index f05bd54c..94839147 100644 --- a/objects/PlayerCards.2d30ee.json +++ b/objects/PlayerCards.2d30ee.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"playercards/PlayerCardPanel\")", "LuaScriptState": "{\"spawnBagState\":{\"placed\":[],\"placedObjects\":[]}}", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayerCardPanel\"}", "Name": "Custom_Tile", "Nickname": "Player Cards", "Snap": true, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index ce714318..afb6d149 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -346,7 +346,7 @@ "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat1White.8b081b.luascriptstate", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"Playermat\"}", + "Memo": "White", "Name": "Custom_Tile", "Nickname": "Playermat 1: White", "Snap": true, diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index d0bc1be6..a0c7a9a1 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -346,7 +346,7 @@ "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"Playermat\"}", + "Memo": "Orange", "Name": "Custom_Tile", "Nickname": "Playermat 2: Orange", "Snap": true, diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index 4f9a6292..1f22c5f7 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -346,7 +346,7 @@ "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"Playermat\"}", + "Memo": "Green", "Name": "Custom_Tile", "Nickname": "Playermat 3: Green", "Snap": true, diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 862ad7d1..68a96ac7 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -346,7 +346,7 @@ "LuaScript": "require(\"playermat/Playmat\")", "LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"Playermat\"}", + "Memo": "Red", "Name": "Custom_Tile", "Nickname": "Playermat 4: Red", "Snap": true, diff --git a/objects/Resources.4406f0.json b/objects/Resources.4406f0.json index 27ee263a..d0ad1b7c 100644 --- a/objects/Resources.4406f0.json +++ b/objects/Resources.4406f0.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.816d84.json b/objects/Resources.816d84.json index 56ea1b61..de7dc10a 100644 --- a/objects/Resources.816d84.json +++ b/objects/Resources.816d84.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.a4b60d.json b/objects/Resources.a4b60d.json index 16f3cbfb..16acd881 100644 --- a/objects/Resources.a4b60d.json +++ b/objects/Resources.a4b60d.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resources.cd15ac.json b/objects/Resources.cd15ac.json index d98591a4..d87f1ff2 100644 --- a/objects/Resources.cd15ac.json +++ b/objects/Resources.cd15ac.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/GenericCounter\")", "LuaScriptState": "5", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"ResourceCounter\"}", "Name": "Custom_Token", "Nickname": "Resources", "Snap": true, diff --git a/objects/Resourcetokens.9fadf9.json b/objects/Resourcetokens.9fadf9.json index a39181d0..06da43f5 100644 --- a/objects/Resourcetokens.9fadf9.json +++ b/objects/Resourcetokens.9fadf9.json @@ -39,7 +39,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"ResourceTokenBag\"}", "MeshIndex": -1, "Name": "Custom_Model_Infinite_Bag", "Nickname": "Resource tokens", diff --git a/objects/RulesReference.d99993.json b/objects/RulesReference.d99993.json index b00713d6..4de14917 100644 --- a/objects/RulesReference.d99993.json +++ b/objects/RulesReference.d99993.json @@ -30,7 +30,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"RulesReference\"}", "Name": "Custom_PDF", "Nickname": "Rules Reference", "Snap": true, diff --git a/objects/SCEDTour.0e5aa8.json b/objects/SCEDTour.0e5aa8.json index c75ad261..8709156c 100644 --- a/objects/SCEDTour.0e5aa8.json +++ b/objects/SCEDTour.0e5aa8.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"core/tour/TourStarter\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TourStarter\"}", "Name": "Custom_Token", "Nickname": "SCED Tour", "Snap": true, diff --git a/objects/ScriptingTrigger.a2f932.json b/objects/ScriptingTrigger.a2f932.json index bf81ab5a..faded6f2 100644 --- a/objects/ScriptingTrigger.a2f932.json +++ b/objects/ScriptingTrigger.a2f932.json @@ -25,7 +25,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayAreaZone\"}", "Name": "ScriptingTrigger", "Nickname": "", "Snap": true, diff --git a/objects/SoundCube.3c988f.json b/objects/SoundCube.3c988f.json index fb205aeb..431b9499 100644 --- a/objects/SoundCube.3c988f.json +++ b/objects/SoundCube.3c988f.json @@ -31,7 +31,6 @@ "LuaScript": "", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"SoundCube\"}", "Name": "Custom_Assetbundle", "Nickname": "SoundCube", "Snap": true, diff --git a/objects/ThePathtoCarcosa.aca04c.json b/objects/ThePathtoCarcosa.aca04c.json index c7c855cd..dd39ca10 100644 --- a/objects/ThePathtoCarcosa.aca04c.json +++ b/objects/ThePathtoCarcosa.aca04c.json @@ -45,7 +45,6 @@ "LuaScript": "require(\"core/DownloadBox\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"CampaignThePathToCarcosa\"}", "Name": "Custom_Model", "Nickname": "The Path to Carcosa", "Snap": true, diff --git a/objects/TokenArranger.022907.json b/objects/TokenArranger.022907.json index 4fb6d2fc..19ab79ff 100644 --- a/objects/TokenArranger.022907.json +++ b/objects/TokenArranger.022907.json @@ -36,7 +36,6 @@ "LuaScript": "require(\"accessories/TokenArranger\")", "LuaScriptState_path": "TokenArranger.022907.luascriptstate", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenArranger\"}", "Name": "Custom_Token", "Nickname": "Token Arranger", "Snap": true, diff --git a/objects/TokenSource.124381.json b/objects/TokenSource.124381.json index 138ba64d..7b6b34fb 100644 --- a/objects/TokenSource.124381.json +++ b/objects/TokenSource.124381.json @@ -37,7 +37,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenSource\"}", "MeshIndex": -1, "Name": "Bag", "Nickname": "Token Source", diff --git a/objects/TokenSpawnTracker.e3ffc9.json b/objects/TokenSpawnTracker.e3ffc9.json index 8709a748..0c4e1527 100644 --- a/objects/TokenSpawnTracker.e3ffc9.json +++ b/objects/TokenSpawnTracker.e3ffc9.json @@ -24,7 +24,6 @@ "LuaScript": "require(\"core/token/TokenSpawnTracker\")", "LuaScriptState": "{\"cards\":[]}", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenSpawnTracker\"}", "Name": "Checker_white", "Nickname": "Token Spawn Tracker", "Snap": true, diff --git a/objects/Trash.147e80.json b/objects/Trash.147e80.json index 7d71eb3a..493eeef7 100644 --- a/objects/Trash.147e80.json +++ b/objects/Trash.147e80.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"White\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.4b8594.json b/objects/Trash.4b8594.json index d227616b..b3d8e954 100644 --- a/objects/Trash.4b8594.json +++ b/objects/Trash.4b8594.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Red\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.5f896a.json b/objects/Trash.5f896a.json index 83f9df28..c0aed51b 100644 --- a/objects/Trash.5f896a.json +++ b/objects/Trash.5f896a.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Green\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.70b9f6.json b/objects/Trash.70b9f6.json index 0ca6bbea..9157562a 100644 --- a/objects/Trash.70b9f6.json +++ b/objects/Trash.70b9f6.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/Trash.f7b6c8.json b/objects/Trash.f7b6c8.json index 1923f48f..a5fc05c6 100644 --- a/objects/Trash.f7b6c8.json +++ b/objects/Trash.f7b6c8.json @@ -38,7 +38,6 @@ "LuaScriptState": "", "MaterialIndex": -1, "MeasureMovement": false, - "Memo": "{\"matColor\":\"Orange\",\"type\":\"Trash\"}", "MeshIndex": -1, "Name": "Custom_Model_Bag", "Nickname": "Trash", diff --git a/objects/VictoryDisplay.6ccd6d.json b/objects/VictoryDisplay.6ccd6d.json index 7834f0a9..622ccfd8 100644 --- a/objects/VictoryDisplay.6ccd6d.json +++ b/objects/VictoryDisplay.6ccd6d.json @@ -158,7 +158,6 @@ "LuaScript": "require(\"core/VictoryDisplay\")", "LuaScriptState": "", "MeasureMovement": false, - "Memo": "{\"matColor\":\"Mythos\",\"type\":\"VictoryDisplay\"}", "Name": "Custom_Token", "Nickname": "Victory Display", "Snap": false, diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 65fbd108..7084f679 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -5,6 +5,8 @@ local optionPanelApi = require("core/OptionPanelApi") local playAreaApi = require("core/PlayAreaApi") local playmatApi = require("playermat/PlaymatApi") +local guidHandler = getObjectsWithTag("GUIDs")[1] + local campaignTokenData = { Name = "Custom_Model", Transform = { @@ -163,7 +165,8 @@ function createCampaignFromToken(importData) Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5) -- destroy Tour Starter token - getObjectsWithTag("TourStarter")[1].destruct() + local tourStarter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TourStarter" }) + tourStarter.destruct() -- restore PlayArea image playAreaApi.updateSurface(importData["playmat"]) diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index c82339c5..ac4d4fc5 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -10,6 +10,8 @@ local playmatApi = require("playermat/PlaymatApi") local soundCubeApi = require("core/SoundCubeApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") +local guidHandler = getObjectsWithTag("GUIDs")[1] + -- objects with this tag will be ignored local IGNORE_TAG = "CleanUpHelper_ignore" @@ -143,7 +145,7 @@ end -- reset doom on agenda function resetDoomCounter() - local doomCounter = getObjectsWithTag("DoomCounter")[1] + local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) if doomCounter ~= nil then doomCounter.call("updateVal") else @@ -228,7 +230,7 @@ end function discardHands() if not options["tidyPlayermats"] then return end for i = 1, 4 do - local trash = getObjectsWithAllTags({COLORS[i], "Trash"}) + local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) if trash == nil then return end local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects() for j = #hand, 1, -1 do @@ -239,8 +241,8 @@ end -- clean up for play area function tidyPlayareaCoroutine() - local trash = getObjectsWithAllTags({"Mythos", "Trash"}) - local playAreaZone = getObjectsWithTag("PlayAreaZone")[1] + local trash = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) + local playAreaZone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) if playAreaZone == nil then printToAll("Scripting zone for main play area could not be found!", "Red") @@ -270,7 +272,7 @@ function tidyPlayerMatCoroutine() for k = 1, 30 do coroutine.yield(0) end -- get respective trash - local trash = getObjectsWithAllTags({COLORS[i], "Trash"}) + local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) if trash == nil then printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red") return 1 @@ -300,7 +302,7 @@ function tidyPlayerMatCoroutine() -- reset "activeInvestigatorId" if i < 5 then - local playermat = getObjectsWithAllTags({COLORS[i], "Playermat"}) + local playermat = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Playermat" }) if playermat then playermat.setVar("activeInvestigatorId", "00000") end @@ -308,7 +310,7 @@ function tidyPlayerMatCoroutine() end end - local datahelper = getObjectsWithTag("DataHelper")[1] + local datahelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) if datahelper then datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {}) end diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 47afb77f..7f2dee07 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -1,11 +1,12 @@ do local TokenArrangerApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] -- 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 = getObjectsWithTag("TokenArranger")[1] + local tokenArranger = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenArranger" }) if tokenArranger ~= nil then tokenArranger.call(functionName, argument) end diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 13e6202b..0ada1a1d 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -1,5 +1,6 @@ do local DeckImporterApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] -- 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 @@ -13,7 +14,7 @@ do -- investigators: True if investigator cards should be spawned DeckImporterApi.getUiState = function() local passthroughTable = {} - local DeckImporter = getObjectsWithTag("DeckImporter")[1] + local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) for k,v in pairs(DeckImporter.call("getUiState")) do passthroughTable[k] = v end @@ -31,7 +32,7 @@ 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) - local DeckImporter = getObjectsWithTag("DeckImporter")[1] + local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) return DeckImporter.call("setUiState", uiStateTable) end diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index 0a97644d..f4861587 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,14 +1,14 @@ do local BlessCurseManagerApi = {} - local internal = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] - internal.getManager = function() - return getObjectsWithTag("BlessCurseManager")[1] + local function getManager() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "BlessCurseManager" }) end -- removes all taken tokens and resets the counts BlessCurseManagerApi.removeTakenTokensAndReset = function() - local BlessCurseManager = internal.getManager() + local BlessCurseManager = getManager() 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) @@ -16,30 +16,30 @@ do -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.sealedToken = function(type, guid) - internal.getManager().call("sealedToken", { type = type, guid = guid }) + getManager().call("sealedToken", { type = type, guid = guid }) end -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.releasedToken = function(type, guid) - internal.getManager().call("releasedToken", { type = type, guid = guid }) + getManager().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) - internal.getManager().call("broadcastStatus", playerColor) + getManager().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) - internal.getManager().call("doRemove", playerColor) + getManager().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) - internal.getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) + getManager().call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) end return BlessCurseManagerApi diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index aa133b09..c70fcead 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -4,6 +4,7 @@ local options = { Playarea = true, Playermats = true } +local guidHandler = getObjectsWithTag("GUIDs")[1] val = 0 @@ -64,7 +65,7 @@ function startReset() if options.Agenda then updateVal(0) end - local DoomInPlayCounter = getObjectsWithTag("DoomInPlayCounter")[1] + local DoomInPlayCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomInPlayCounter" }) if DoomInPlayCounter then DoomInPlayCounter.call("removeDoom", options) end diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 0d86b260..4688efd5 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,5 +1,7 @@ local playmatApi = require("playermat/PlaymatApi") +local guidHandler = getObjectsWithTag("GUIDs")[1] + local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" @@ -29,8 +31,8 @@ function onLoad() color = { 0, 0, 0, 0 } }) - TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) - ZONE = getObjectsWithAllTags({"Mythos", "PlayAreaZone" }) + TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) + ZONE = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) loopID = Wait.time(countDoom, 2, -1) end diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua new file mode 100644 index 00000000..1a187064 --- /dev/null +++ b/src/core/GUIDReferenceHandler.ttslua @@ -0,0 +1,99 @@ +local GuidReferences = { + White = { + ClueCounter = "d86b7c", + ClickableClueCounter = "db85d6", + DamageCounter = "eb08d6", + HandZone = "a70eee", + HorrorCounter = "468e88", + InvestigatorSkillTracker = "e598c2", + Playermat = "8b081b", + ResourceCounter = "4406f0", + Trash = "147e80" + }, + Orange = { + ClueCounter = "1769ed", + ClickableClueCounter = "3f22e5", + DamageCounter = "e64eec", + HandZone = "5fe087", + HorrorCounter = "0257d9", + InvestigatorSkillTracker = "b4a5f7", + Playermat = "bd0ff4", + ResourceCounter = "816d84", + Trash = "f7b6c8" + }, + Green = { + ClueCounter = "032300", + ClickableClueCounter = "891403", + DamageCounter = "1f5a0a", + HandZone = "0285cc", + HorrorCounter = "7b5729", + InvestigatorSkillTracker = "af7ed7", + Playermat = "383d8b", + ResourceCounter = "cd15ac", + Trash = "5f896a" + }, + Red = { + ClueCounter = "37be78", + ClickableClueCounter = "4111de", + DamageCounter = "591a45", + HandZone = "be2f17", + HorrorCounter = "beb964", + InvestigatorSkillTracker = "e74881", + Playermat = "0840d5", + ResourceCounter = "a4b60d", + Trash = "4b8594" + }, + Mythos = { + AllCardsBag = "15bb07", + BlessCurseManager = "5933fb", + CampaignThePathToCarcosa = "aca04c", + DataHelper = "708279", + DeckImporter = "a28140", + DoomCounter = "85c4c6", + DoomInPlayCounter = "652ff3", + MasterClueCounter = "4a3aa4", + MythosArea = "9f334f", + NavigationOverlayHandler = "797ede", + OptionPanelSource = "830bd0", + PlayArea = "721ba2", + PlayAreaZone = "a2f932", + PlayerCardPanel = "2d30ee", + ResourceTokenBag = "9fadf9", + RulesReference = "d99993", + SoundCube = "3c988f", + TokenArranger = "022907", + TokenSource = "124381", + TokenSpawnTracker = "e3ffc9", + TourStarter = "0e5aa8", + Trash = "70b9f6", + VictoryDisplay = "6ccd6d" + } +} + +function getObjectByOwnerAndType(param) + local owner = param.owner + local type = param.type + return getObjectFromGUID(GuidReferences[owner][type]) +end + +function getObjectsByType(type) + local objList = {} + for owner, objects in pairs(GuidReferences) do + local obj = getObjectFromGUID(objects[type]) + if obj then + objList[owner] = obj + end + end + return objList +end + +function getObjectsByOwner(owner) + local objList = {} + for type, guid in pairs(GuidReferences[owner]) do + local obj = getObjectFromGUID(guid) + if obj then + objList[type] = obj + end + end + return objList +end diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 4d6043c4..aaee28aa 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -3,6 +3,8 @@ local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") +local guidHandler = getObjectsWithTag("GUIDs")[1] + function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Bless/Curse Status", showBlessCurseStatus) @@ -41,7 +43,8 @@ end -- adds 1 doom to the agenda function addDoomToAgenda() - getObjectsWithTag("DoomCounter")[1].call("addVal", 1) + local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) + doomCounter.call("addVal", 1) end -- moves the hovered card to the victory display diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 1863657c..4a78850a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -8,6 +8,8 @@ local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") +local guidHandler = getObjectsWithTag("GUIDs")[1] + --------------------------------------------------------- -- general setup --------------------------------------------------------- @@ -127,7 +129,7 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - DATA_HELPER = getObjectsWithTag("DataHelper")[1] + --DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) resetChaosTokenStatTracker() getModVersion() math.randomseed(os.time()) @@ -957,7 +959,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 = getObjectsWithTag("OptionPanelSource")[1] + local sourceBag = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "OptionPanelSource" }) -- error handling for missing sourceBag if not sourceBag then diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 4b35372b..c0f63408 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -3,6 +3,8 @@ local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") +local guidHandler = getObjectsWithTag("GUIDs")[1] + local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, lowerRight = { x = 0.86, z = 0.38 }, @@ -33,8 +35,8 @@ function onLoad(saveState) useFrontData = loadedState.useFrontData or true tokenData = loadedState.tokenData or {} end - TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) - DATA_HELPER = getObjectsWithTag("DataHelper")[1] + TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) + DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) collisionEnabled = true end diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 4f08509e..702c538d 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -1,16 +1,19 @@ do local MythosAreaApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] + + local function getMythosArea() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MythosArea" }) + end -- returns the chaos token metadata (if provided through scenario reference card) MythosAreaApi.returnTokenData = function() - local MythosArea = getObjectsWithTag("MythosArea")[1] - return MythosArea.call("returnTokenData") + getMythosArea().call("returnTokenData") end -- draw an encounter card to the requested position/rotation MythosAreaApi.drawEncounterCard = function(pos, rotY, alwaysFaceUp) - local MythosArea = getObjectsWithTag("MythosArea")[1] - MythosArea.call("drawEncounterCard", { + getMythosArea().call("drawEncounterCard", { pos = pos, rotY = rotY, alwaysFaceUp = alwaysFaceUp diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index b1e92dd5..995fdbaf 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -1,12 +1,16 @@ do local NavigationOverlayApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] + + local function getNOHandler() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "NavigationOverlayHandler" }) + end -- 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) - local handler = getObjectsWithTag("NavigationOverlayHandler")[1] - handler.call("copyVisibility", { + getNOHandler().call("copyVisibility", { startColor = startColor, targetColor = targetColor }) @@ -15,8 +19,7 @@ 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) - local handler = getObjectsWithTag("NavigationOverlayHandler")[1] - handler.call("cycleVisibility", playerColor) + getNOHandler().call("cycleVisibility", playerColor) end return NavigationOverlayApi diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index e80cffd1..4a360321 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -2,6 +2,8 @@ -- general setup --------------------------------------------------------- +local guidHandler = getObjectsWithTag("GUIDs")[1] + -- Location connection directional options local BIDIRECTIONAL = 0 local ONE_WAY = 1 @@ -506,7 +508,7 @@ function shiftContentsRight(playerColor) end function shiftContents(playerColor, direction) - local zone = getObjectsWithTag("PlayAreaZone")[1] + local zone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) if not zone then broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") return diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 66dad51c..54291f5f 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,105 +1,109 @@ do local PlayAreaApi = {} - local internal = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] - internal.getPlayArea = function() - return getObjectsWithTag("PlayArea")[1] + local function getPlayArea() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayArea" }) + end + + local function getInvestigatorCounter() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "InvestigatorCounter" }) end -- 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 getObjectsWithTag("InvestigatorCounter")[1].getVar("val") + getInvestigatorCounter().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 getObjectsWithTag("InvestigatorCounter")[1].call("updateVal", count) + getInvestigatorCounter().call("updateVal", count) end -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain -- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' ---@param playerColor Color Color of the player requesting the shift for messages PlayAreaApi.shiftContentsUp = function(playerColor) - return internal.getPlayArea().call("shiftContentsUp", playerColor) + return getPlayArea().call("shiftContentsUp", playerColor) end PlayAreaApi.shiftContentsDown = function(playerColor) - return internal.getPlayArea().call("shiftContentsDown", playerColor) + return getPlayArea().call("shiftContentsDown", playerColor) end PlayAreaApi.shiftContentsLeft = function(playerColor) - return internal.getPlayArea().call("shiftContentsLeft", playerColor) + return getPlayArea().call("shiftContentsLeft", playerColor) end PlayAreaApi.shiftContentsRight = function(playerColor) - return internal.getPlayArea().call("shiftContentsRight", playerColor) + return getPlayArea().call("shiftContentsRight", playerColor) end -- Reset the play area's tracking of which cards have had tokens spawned. PlayAreaApi.resetSpawnedCards = function() - return internal.getPlayArea().call("resetSpawnedCards") + return getPlayArea().call("resetSpawnedCards") end -- Event to be called when the current scenario has changed. ---@param scenarioName Name of the new scenario PlayAreaApi.onScenarioChanged = function(scenarioName) - internal.getPlayArea().call("onScenarioChanged", scenarioName) + getPlayArea().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) - internal.getPlayArea().call("setLimitSnapsByType", matchCardTypes) + getPlayArea().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) - internal.getPlayArea().call("tryObjectEnterContainer", { container = container, object = object }) + getPlayArea().call("tryObjectEnterContainer", { container = container, object = object }) end -- counts the VP on locations in the play area PlayAreaApi.countVP = function() - return internal.getPlayArea().call("countVP") + return getPlayArea().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 internal.getPlayArea().call("highlightMissingData", state) + return getPlayArea().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 internal.getPlayArea().call("highlightCountedVP", state) + return getPlayArea().call("highlightCountedVP", state) end -- Checks if an object is in the play area (returns true or false) PlayAreaApi.isInPlayArea = function(object) - return internal.getPlayArea().call("isInPlayArea", object) + return getPlayArea().call("isInPlayArea", object) end PlayAreaApi.getSurface = function() - return internal.getPlayArea().getCustomObject().image + return getPlayArea().getCustomObject().image end PlayAreaApi.updateSurface = function(url) - return internal.getPlayArea().call("updateSurface", url) + return getPlayArea().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) - internal.getPlayArea().call("updateLocations", args) + getPlayArea().call("updateLocations", args) end PlayAreaApi.getCustomDataHelper = function() - return internal.getPlayArea().getVar("customDataHelper") + return getPlayArea().getVar("customDataHelper") end return PlayAreaApi diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 13d11fa3..0339f519 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -1,5 +1,6 @@ do local SoundCubeApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] -- this table links the name of a trigger effect to its index local soundIndices = { @@ -9,7 +10,7 @@ do } local function playTriggerEffect(index) - local SoundCube = getObjectsWithTag("SoundCube")[1] + local SoundCube = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "SoundCube" }) SoundCube.AssetBundle.playTriggerEffect(index) end diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index f706ba63..36680eff 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -10,12 +10,10 @@ local countedVP = {} local highlightMissing = false local highlightCounted = false -local TRASH +local guidHandler = getObjectsWithTag("GUIDs")[1] -- button creation when loading the game function onLoad() - TRASH = getObjectsWithAllTags({"Mythos", "Trash"}) - -- index 0: VP - "Display" local buttonParameters = {} buttonParameters.label = "0" @@ -235,8 +233,7 @@ end function highlightCountedVP() self.editButton({ index = 4, - tooltip = (highlightCounted and "Enable" or "Disable") .. - " highlighting of cards with VP." + tooltip = (highlightCounted and "Enable" or "Disable") .. " highlighting of cards with VP." }) for _, obj in pairs(countedVP) do if obj ~= nil then @@ -253,6 +250,8 @@ end -- places the provided card in the first empty spot function placeCard(card) + local TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) + -- check snap point states local snaps = self.getSnapPoints() table.sort(snaps, function(a, b) return a.position.x > b.position.x end) diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index 6dc0fad4..dc14fe0a 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -1,19 +1,22 @@ do local VictoryDisplayApi = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] + + local function getVictoryDisplay() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }) + end -- triggers an update of the Victory count ---@param delay Number Delay in seconds after which the update call is executed VictoryDisplayApi.update = function(delay) - local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1] - VictoryDisplay.call("startUpdate", delay) + getVictoryDisplay().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 - local VictoryDisplay = getObjectsWithTag("VictoryDisplay")[1] - VictoryDisplay.call("placeCard", object) + getVictoryDisplay().call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }).call("placeCard", object) end end diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index bd4972ea..91504bd6 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -3,6 +3,8 @@ do local playAreaApi = require("core/PlayAreaApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") + local guidHandler = getObjectsWithTag("GUIDs")[1] + local PLAYER_CARD_TOKEN_OFFSETS = { [1] = { Vector(0, 3, -0.2) @@ -335,7 +337,7 @@ do return end tokenTemplates = { } - local tokenSource = getObjectsWithTag("TokenSource")[1] + local tokenSource = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSource" }) for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do local tokenName = tokenTemplate.Memo tokenTemplates[tokenName] = tokenTemplate @@ -347,7 +349,7 @@ do if playerCardData ~= nil then return end - local dataHelper = getObjectsWithTag("DataHelper")[1] + local dataHelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA') end diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index 21eaf9da..23cf7b8f 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,33 +1,33 @@ do local TokenSpawnTracker = {} - local internal = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] - internal.getSpawnTracker = function() - return getObjectsWithTag("TokenSpawnTracker")[1] + local function getSpawnTracker() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSpawnTracker" }) end TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) - return internal.getSpawnTracker().call("hasSpawnedTokens", cardGuid) + return getSpawnTracker().call("hasSpawnedTokens", cardGuid) end TokenSpawnTracker.markTokensSpawned = function(cardGuid) - return internal.getSpawnTracker().call("markTokensSpawned", cardGuid) + return getSpawnTracker().call("markTokensSpawned", cardGuid) end TokenSpawnTracker.resetTokensSpawned = function(cardGuid) - return internal.getSpawnTracker().call("resetTokensSpawned", cardGuid) + return getSpawnTracker().call("resetTokensSpawned", cardGuid) end TokenSpawnTracker.resetAllAssetAndEvents = function() - return internal.getSpawnTracker().call("resetAllAssetAndEvents") + return getSpawnTracker().call("resetAllAssetAndEvents") end TokenSpawnTracker.resetAllLocations = function() - return internal.getSpawnTracker().call("resetAllLocations") + return getSpawnTracker().call("resetAllLocations") end TokenSpawnTracker.resetAll = function() - return internal.getSpawnTracker().call("resetAll") + return getSpawnTracker().call("resetAll") end return TokenSpawnTracker diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 322b2aad..8b0387f5 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -1,9 +1,9 @@ do local AllCardsBagApi = {} - local internal = {} + local guidHandler = getObjectsWithTag("GUIDs")[1] - internal.getAllCardsBag = function() - return getObjectsWithTag("AllCardsBag")[1] + local function getAllCardsBag() + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "AllCardsBag" }) end -- Returns a specific card from the bag, based on ArkhamDB ID @@ -14,7 +14,7 @@ do -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata AllCardsBagApi.getCardById = function(id) - internal.getAllCardsBag().call("getCardById", {id = id}) + return getAllCardsBag().call("getCardById", {id = id}) end -- Gets a random basic weakness from the bag. Once a given ID has been returned @@ -23,11 +23,11 @@ do -- weaknesses. ---@return id String ID of the selected weakness. AllCardsBagApi.getRandomWeaknessId = function() - internal.getAllCardsBag().call("getRandomWeaknessId") + return getAllCardsBag().call("getRandomWeaknessId") end AllCardsBagApi.isIndexReady = function() - internal.getAllCardsBag().call("isIndexReady") + return getAllCardsBag().call("isIndexReady") end -- Called by Hotfix bags when they load. If we are still loading indexes, then @@ -36,7 +36,7 @@ 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() - internal.getAllCardsBag().call("rebuildIndexForHotfix") + return getAllCardsBag().call("rebuildIndexForHotfix") end -- Searches the bag for cards which match the given name and returns a list. Note that this is @@ -44,11 +44,11 @@ do ---@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) - internal.getAllCardsBag().call("getCardsByName", {name = name, exact = exact}) + return getAllCardsBag().call("getCardsByName", {name = name, exact = exact}) end AllCardsBagApi.isBagPresent = function() - internal.getAllCardsBag() and true + return getAllCardsBag() and true end -- Returns a list of cards from the bag matching a class and level (0 or upgraded) @@ -59,15 +59,15 @@ do -- cardData: TTS object data, suitable for spawning the card -- cardMetadata: Table of parsed metadata AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded) - internal.getAllCardsBag().call("getCardsByClassAndLevel", {class = class, upgraded = upgraded}) + return getAllCardsBag().call("getCardsByClassAndLevel", {class = class, upgraded = upgraded}) end AllCardsBagApi.getCardsByCycle = function(cycle) - internal.getAllCardsBag().call("getCardsByCycle", cycle) + return getAllCardsBag().call("getCardsByCycle", cycle) end AllCardsBagApi.getUniqueWeaknesses = function() - internal.getAllCardsBag().call("getUniqueWeaknesses") + return getAllCardsBag().call("getUniqueWeaknesses") end return AllCardsBagApi diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 45985fde..251fb070 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -7,13 +7,12 @@ local validCountItemList = { ["Clue"] = 1, [""] = 1 } -local MATCOLOR, TRASH exposedValue = 0 function onLoad() self.createButton({ label = "", - click_function = "removeAllClues", + click_function = "countItems", function_owner = self, position = { 0, 0.1, 0 }, height = 0, @@ -21,9 +20,6 @@ function onLoad() font_color = { 0, 0, 0 }, font_size = 2000 }) - -- set MATCOLOR based on memo - MATCOLOR = JSON.decode(self.getMemo()).matColor - TRASH = getObjectsWithAllTags({MATCOLOR, "Trash"}) loopID = Wait.time(countItems, 1, -1) end @@ -69,20 +65,8 @@ function findValidItemsInSphere() return retval end -function removeAllClues() - startLuaCoroutine(self, "clueRemovalCoroutine") -end - -function clueRemovalCoroutine() - for _, entry in ipairs(findValidItemsInSphere()) do - -- Do not put the table in the garbage - if entry.hit_object.getGUID() ~= "4ee1f2" then - -- delay for animation purposes - for k = 1, 10 do - coroutine.yield(0) - end - TRASH.putObject(entry.hit_object) - end +function removeAllClues(trash) + for _, obj in ipairs(findValidItemsInSphere()) do + trash.putObject(obj) end - return 1 -end +end \ No newline at end of file diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index dc5858a9..586fa356 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -4,6 +4,8 @@ local navigationOverlayApi = require("core/NavigationOverlayApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") +local guidHandler = getObjectsWithTag("GUIDs")[1] + -- set true to enable debug logging and show Physics.cast() local DEBUG = false @@ -83,7 +85,7 @@ activeInvestigatorId = "00000" -- table of type-object reference pairs of all owned objects local ownedObjects = {} -local matColor = JSON.decode(self.getMemo()).matColor +local matColor = self.getMemo() -- variable to track the status of the "Show Draw Button" option local isDrawButtonVisible = false @@ -103,7 +105,7 @@ function onLoad(saveState) self.interactable = DEBUG -- get object references to owned objects - getOwnedObjects() + ownedObjects = guidHandler.call("getObjectsByOwner", matColor) -- button creation for i = 1, 6 do @@ -152,13 +154,6 @@ function onLoad(saveState) math.randomseed(os.time()) end -function getOwnedObjects() - local objList = getObjectsWithTag(matColor) - for _, obj in ipairs(objList) do - - end -end - --------------------------------------------------------- -- utility functions --------------------------------------------------------- @@ -873,7 +868,7 @@ function clickableClues(showCounter) clueCount = ownedObjects.ClueCounter.getVar("exposedValue") -- remove clues - ownedObjects.ClueCounter.call("removeAllClues") + ownedObjects.ClueCounter.call("removeAllClues", ownedObjects.Trash) -- set value for clue clickers ownedObjects.ClickableClueCounter.call("updateVal", clueCount) @@ -900,7 +895,7 @@ end -- removes all clues (moving tokens to the trash and setting counters to 0) function removeClues() - ownedObjects.ClueCounter.call("removeAllClues") + ownedObjects.ClueCounter.call("removeAllClues", ownedObjects.Trash) ownedObjects.ClickableClueCounter.call("updateVal", 0) end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 2250bbe0..656df813 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -163,7 +163,7 @@ do ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) for _, mat in ipairs(internal.getMatForColor(matColor)) do - mat.call("updateCounter", {type = type, newValue = newValue, modifier = modifier}) + mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier }) end end @@ -216,10 +216,11 @@ do ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@return array Table Single-element if only single playmat is requested internal.getMatForColor = function(matColor) + local guidHandler = getObjectsWithTag("GUIDs")[1] if matColor == "All" then - return getObjectsWithTag("Playermat") + return guidHandler.call("getObjectsByType", "Playermat") else - return {matColor = getObjectsWithAllTags({matColor, "Playermat"}) } + return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } end end From 47004e773add4f88aa29538d4545adbe1bb54326 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 13:54:02 +0200 Subject: [PATCH 25/76] bundle -> unbundle --- config.json | 1 + .../BuffytheVampireSlayer.6bf40f.json | 2 +- .../CartoonInvestigators.524fbc.json | 6 +++--- .../CircusExMortisInvestigatorExpansion.195936.json | 2 +- .../CityofSecrets.1ee775.json | 2 +- .../TheGhostsOfOnigawaInvestigatorExpansion.c19cfa.json | 6 +++--- .../TheRedCoterie.de13e3.json | 2 +- .../TheSandsOfMemphisInvestigatorExpansion.073201.json | 8 ++++---- .../Fan-MadeCampaigns.89c32e/HeartofDarkness.cc95ff.json | 2 +- .../Fan-MadeCampaigns.89c32e/SoulsofDarkness.a94e6b.json | 2 +- .../TheSandsOfMemphisCampaignExpansion.2634e3.json | 2 +- objects/GUIDReferenceHandler.da23e4.json | 2 +- 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/config.json b/config.json index f688047f..3419252a 100644 --- a/config.json +++ b/config.json @@ -3,6 +3,7 @@ "ComponentTags_path": "ComponentTags.json", "CustomUIAssets_path": "CustomUIAssets.json", "DecalPallet_path": "DecalPallet.json", + "Decals": [], "GameComplexity": "", "GameMode": "Arkham Horror LCG - Super Complete Edition", "GameType": "", diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/BuffytheVampireSlayer.6bf40f.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/BuffytheVampireSlayer.6bf40f.json index b0cf6ef3..fc5a3615 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/BuffytheVampireSlayer.6bf40f.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/BuffytheVampireSlayer.6bf40f.json @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CartoonInvestigators.524fbc.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CartoonInvestigators.524fbc.json index 99383f67..76b6d05d 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CartoonInvestigators.524fbc.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CartoonInvestigators.524fbc.json @@ -49,6 +49,9 @@ "Nickname": "Cartoon Investigators", "Snap": true, "Sticky": true, + "Tags": [ + "LargeBox" + ], "Tooltip": true, "Transform": { "posX": -23.615, @@ -61,9 +64,6 @@ "scaleY": 0.14, "scaleZ": 1 }, - "Tags": [ - "LargeBox" - ], "Value": 0, "XmlUI": "" } diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CircusExMortisInvestigatorExpansion.195936.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CircusExMortisInvestigatorExpansion.195936.json index a5885da6..18a97fe3 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CircusExMortisInvestigatorExpansion.195936.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CircusExMortisInvestigatorExpansion.195936.json @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CityofSecrets.1ee775.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CityofSecrets.1ee775.json index b610bb61..85297ebc 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CityofSecrets.1ee775.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/CityofSecrets.1ee775.json @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheGhostsOfOnigawaInvestigatorExpansion.c19cfa.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheGhostsOfOnigawaInvestigatorExpansion.c19cfa.json index e02967eb..9116ff90 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheGhostsOfOnigawaInvestigatorExpansion.c19cfa.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheGhostsOfOnigawaInvestigatorExpansion.c19cfa.json @@ -49,6 +49,9 @@ "Nickname": "The Ghosts Of Onigawa (Investigator Expansion)", "Snap": true, "Sticky": true, + "Tags": [ + "LargeBox" + ], "Tooltip": true, "Transform": { "posX": -47.192, @@ -61,9 +64,6 @@ "scaleY": 0.14, "scaleZ": 1 }, - "Tags": [ - "LargeBox" - ], "Value": 0, "XmlUI": "" } diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheRedCoterie.de13e3.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheRedCoterie.de13e3.json index 1d5c0d22..cc3c7e26 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheRedCoterie.de13e3.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheRedCoterie.de13e3.json @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheSandsOfMemphisInvestigatorExpansion.073201.json b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheSandsOfMemphisInvestigatorExpansion.073201.json index 637f83eb..4d2f39b3 100644 --- a/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheSandsOfMemphisInvestigatorExpansion.073201.json +++ b/objects/Community-CreatedPlayerCardsInvestigators.ed4ca7/TheSandsOfMemphisInvestigatorExpansion.073201.json @@ -49,6 +49,9 @@ "Nickname": "The Sands Of Memphis (Investigator Expansion)", "Snap": true, "Sticky": true, + "Tags": [ + "LargeBox" + ], "Tooltip": true, "Transform": { "posX": -47.192, @@ -61,9 +64,6 @@ "scaleY": 0.14, "scaleZ": 1 }, - "Tags": [ - "LargeBox" - ], "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/HeartofDarkness.cc95ff.json b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/HeartofDarkness.cc95ff.json index eff7c98e..039e4366 100644 --- a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/HeartofDarkness.cc95ff.json +++ b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/HeartofDarkness.cc95ff.json @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/SoulsofDarkness.a94e6b.json b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/SoulsofDarkness.a94e6b.json index 98af33ba..1b89cf16 100644 --- a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/SoulsofDarkness.a94e6b.json +++ b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/SoulsofDarkness.a94e6b.json @@ -82,4 +82,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/TheSandsOfMemphisCampaignExpansion.2634e3.json b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/TheSandsOfMemphisCampaignExpansion.2634e3.json index af3d64bb..8492fb67 100644 --- a/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/TheSandsOfMemphisCampaignExpansion.2634e3.json +++ b/objects/Fan-MadeScenariosCampaignsMiscellany.66e97c/Fan-MadeCampaigns.89c32e/TheSandsOfMemphisCampaignExpansion.2634e3.json @@ -66,4 +66,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/GUIDReferenceHandler.da23e4.json b/objects/GUIDReferenceHandler.da23e4.json index 4f868304..fd8605f6 100644 --- a/objects/GUIDReferenceHandler.da23e4.json +++ b/objects/GUIDReferenceHandler.da23e4.json @@ -45,4 +45,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} From 8de5fc6b56e8b5631d9e74497a7a7f010846e83f Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 14:08:26 +0200 Subject: [PATCH 26/76] bugfixes --- src/core/Global.ttslua | 24 +++++-------- src/playermat/PlaymatApi.ttslua | 60 +++++++++++++-------------------- 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 4a78850a..136338ad 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -8,8 +8,6 @@ local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") -local guidHandler = getObjectsWithTag("GUIDs")[1] - --------------------------------------------------------- -- general setup --------------------------------------------------------- @@ -31,7 +29,7 @@ local NOT_INTERACTABLE = { "975c39", -- vertical border right } -local DATA_HELPER +local guidHandler, DATA_HELPER local chaosTokens = {} local chaosTokensLastMat = nil local bagSearchers = {} @@ -129,7 +127,8 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - --DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) + guidHandler = getObjectsWithTag("GUIDs")[1] + DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) resetChaosTokenStatTracker() getModVersion() math.randomseed(os.time()) @@ -907,7 +906,7 @@ function applyOptionPanelChange(id, state) for i, color in ipairs(MAT_COLORS) do local pos = playmatApi.transformLocalPosition({0.05, 0, -1.182}, color) local rot = playmatApi.returnRotation(color) - optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot, color) + optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot) end -- option: Show search assistant for each player @@ -915,7 +914,7 @@ function applyOptionPanelChange(id, state) for i, color in ipairs(MAT_COLORS) do local pos = playmatApi.transformLocalPosition({-0.3, 0, -1.182}, color) local rot = playmatApi.returnRotation(color) - optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot, color) + optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot) end -- option: Show attachment helper @@ -942,12 +941,12 @@ end ---@param position Vector Position of the object (where it will spawn) ---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0}) ---@return. GUID of the spawnedObj (or nil if object was removed) -function spawnOrRemoveHelper(state, name, position, rotation, color) +function spawnOrRemoveHelper(state, name, position, rotation) if (type(state) == "table" and #state == 0) then return removeHelperObject(name) elseif state then Player.getPlayers()[1].pingTable(position) - return spawnHelperObject(name, position, rotation, color).getGUID() + return spawnHelperObject(name, position, rotation).getGUID() else return removeHelperObject(name) end @@ -957,8 +956,7 @@ end ---@param name String Name of the object that should be copied ---@param position Table Desired position of the object ---@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) +function spawnHelperObject(name, position, rotation) local sourceBag = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "OptionPanelSource" }) -- error handling for missing sourceBag @@ -977,12 +975,6 @@ 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 diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 656df813..30e4759f 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -6,18 +6,11 @@ do ---@param startPos Table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) local result, smallestDistance - for _, mat in ipairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(internal.getMatForColor("All")) do local distance = Vector.between(startPos, mat.getPosition()):magnitude() if smallestDistance == nil or distance < smallestDistance then smallestDistance = distance - for _, tag in ipairs(mat.getTags) do - if tag == "White" - or tag == "Orange" - or tag == "Green" - or tag == "Red" then - result = tag - end - end + result = matColor end end return result @@ -26,7 +19,7 @@ do -- Returns the color of the player's hand that is seated next to the playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getPlayerColor = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.getVar("playerColor") end end @@ -34,17 +27,10 @@ do -- Returns the color of the playmat that owns the playercolor's hand ---@param handColor String Color of the playmat PlaymatApi.getMatColor = function(handColor) - for _, mat in ipairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(internal.getMatForColor("All")) do local playerColor = mat.getVar("playerColor") if playerColor == handColor then - for _, tag in ipairs(mat.getTags) do - if tag == "White" - or tag == "Orange" - or tag == "Green" - or tag == "Red" then - return tag - end - end + return matColor end end end @@ -52,7 +38,7 @@ do -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.getVar("isDES") end end @@ -60,7 +46,7 @@ do -- Returns the draw deck of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDrawDeck = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end @@ -69,7 +55,7 @@ do -- Returns the position of the discard pile of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.call("returnGlobalDiscardPosition") end end @@ -78,7 +64,7 @@ do ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.positionToWorld(localPos) end end @@ -86,7 +72,7 @@ do -- Returns the rotation of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.getRotation() end end @@ -95,7 +81,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("doUpkeepFromHotkey", playerColor) end end @@ -103,7 +89,7 @@ do -- Returns the active investigator id ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.getVar("activeInvestigatorId") end end @@ -115,7 +101,7 @@ do ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end @@ -124,7 +110,7 @@ do ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end @@ -133,7 +119,7 @@ do ---@param showCounter Boolean Whether the clickable counter should be present or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end @@ -141,7 +127,7 @@ do -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("removeClues") end end @@ -150,7 +136,7 @@ do ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do count = count + mat.call("getClueCount", useClickableCounters) end return count @@ -162,7 +148,7 @@ do ---@param newValue Number Value to set the counter to ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier }) end end @@ -171,7 +157,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") ---@param type String Counter to target PlaymatApi.getCounterValue = function(matColor, type) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do return mat.call("getCounterValue", type) end end @@ -179,7 +165,7 @@ do -- resets the specified skill tracker to "1, 1, 1, 1" ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("resetSkillTracker") end end @@ -189,7 +175,7 @@ do ---@param filter Function Optional filter function (return true for desired objects) PlaymatApi.searchAroundPlaymat = function(matColor, filter) local objList = {} - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do table.insert(objList, obj) end @@ -200,14 +186,14 @@ do -- Discard a non-hidden card from the corresponding player's hand ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) - for _, mat in ipairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(internal.getMatForColor(matColor)) do mat.call("doDiscardOne") end end -- Triggers the metadata sync for all playmats PlaymatApi.syncAllCustomizableCards = function() - for _, mat in ipairs(internal.getMatForColor("All")) do + for _, mat in pairs(internal.getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end From bd1bbb92de701286ef2bcc36332ec440c4f5a28b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 21:16:36 +0200 Subject: [PATCH 27/76] swapped references to GUID handler to GUIDs --- config.json | 2 +- modsettings/ComponentTags.json | 4 -- ....json => GUIDReferenceHandler.123456.json} | 7 +- .../CampaignImporterExporter.ttslua | 2 +- src/accessories/CleanUpHelper.ttslua | 2 +- src/accessories/TokenArrangerApi.ttslua | 2 +- src/arkhamdb/DeckImporterApi.ttslua | 13 ++-- src/chaosbag/BlessCurseManagerApi.ttslua | 2 +- src/core/DoomCounter.ttslua | 2 +- src/core/DoomInPlayCounter.ttslua | 2 +- src/core/GameKeyHandler.ttslua | 2 +- src/core/Global.ttslua | 2 +- src/core/MythosArea.ttslua | 2 +- src/core/MythosAreaApi.ttslua | 2 +- src/core/NavigationOverlayApi.ttslua | 2 +- src/core/PlayArea.ttslua | 2 +- src/core/PlayAreaApi.ttslua | 3 +- src/core/SoundCubeApi.ttslua | 2 +- src/core/VictoryDisplay.ttslua | 2 +- src/core/VictoryDisplayApi.ttslua | 2 +- src/core/token/TokenManager.ttslua | 4 +- src/core/token/TokenSpawnTrackerApi.ttslua | 2 +- src/core/tour/TourManager.ttslua | 5 +- src/core/tour/TourScript.ttslua | 10 +-- src/playercards/AllCardsBagApi.ttslua | 2 +- src/playermat/Playmat.ttslua | 2 +- src/playermat/PlaymatApi.ttslua | 67 +++++++++---------- 27 files changed, 74 insertions(+), 77 deletions(-) rename objects/{GUIDReferenceHandler.da23e4.json => GUIDReferenceHandler.123456.json} (94%) diff --git a/config.json b/config.json index 3419252a..61fdf6ab 100644 --- a/config.json +++ b/config.json @@ -20,7 +20,7 @@ "MusicPlayer_path": "MusicPlayer.json", "Note": "", "ObjectStates_order": [ - "GUIDReferenceHandler.da23e4", + "GUIDReferenceHandler.123456", "HandTrigger.5fe087", "HandTrigger.be2f17", "HandTrigger.0285cc", diff --git a/modsettings/ComponentTags.json b/modsettings/ComponentTags.json index ad3908c8..3e61c8d2 100644 --- a/modsettings/ComponentTags.json +++ b/modsettings/ComponentTags.json @@ -12,10 +12,6 @@ "displayed": "LinkedPhaseTracker", "normalized": "linkedphasetracker" }, - { - "displayed": "chaosBag", - "normalized": "chaosBag" - }, { "displayed": "displacement_excluded", "normalized": "displacement_excluded" diff --git a/objects/GUIDReferenceHandler.da23e4.json b/objects/GUIDReferenceHandler.123456.json similarity index 94% rename from objects/GUIDReferenceHandler.da23e4.json rename to objects/GUIDReferenceHandler.123456.json index fd8605f6..096e5e49 100644 --- a/objects/GUIDReferenceHandler.da23e4.json +++ b/objects/GUIDReferenceHandler.123456.json @@ -13,7 +13,7 @@ "Description": "This object handles GUID references to objects.", "DragSelectable": true, "GMNotes": "", - "GUID": "da23e4", + "GUID": "123456", "Grid": true, "GridProjection": false, "Hands": false, @@ -28,9 +28,6 @@ "Nickname": "GUID Reference Handler", "Snap": true, "Sticky": true, - "Tags": [ - "GUIDs" - ], "Tooltip": true, "Transform": { "posX": 78, @@ -45,4 +42,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 7084f679..8b5e6075 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -5,7 +5,7 @@ local optionPanelApi = require("core/OptionPanelApi") local playAreaApi = require("core/PlayAreaApi") local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local campaignTokenData = { Name = "Custom_Model", diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index ac4d4fc5..c64d2dab 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -10,7 +10,7 @@ local playmatApi = require("playermat/PlaymatApi") local soundCubeApi = require("core/SoundCubeApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- objects with this tag will be ignored local IGNORE_TAG = "CleanUpHelper_ignore" diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 7f2dee07..846c0648 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -1,11 +1,11 @@ do local TokenArrangerApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] -- 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 guidHandler = getObjectFromGUID("123456") local tokenArranger = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenArranger" }) if tokenArranger ~= nil then tokenArranger.call(functionName, argument) diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 0ada1a1d..221a5f5d 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -1,6 +1,11 @@ do local DeckImporterApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] + + + local function getDeckImporter() + local guidHandler = getObjectFromGUID("123456") + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) + end -- 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,8 +19,7 @@ do -- investigators: True if investigator cards should be spawned DeckImporterApi.getUiState = function() local passthroughTable = {} - local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) - for k,v in pairs(DeckImporter.call("getUiState")) do + for k,v in pairs(getDeckImporter().call("getUiState")) do passthroughTable[k] = v end return passthroughTable @@ -32,8 +36,7 @@ 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) - local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) - return DeckImporter.call("setUiState", uiStateTable) + return getDeckImporter().call("setUiState", uiStateTable) end return DeckImporterApi diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index f4861587..d0cd5b9c 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,8 +1,8 @@ do local BlessCurseManagerApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getManager() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "BlessCurseManager" }) end diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index c70fcead..f39ad72d 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -4,7 +4,7 @@ local options = { Playarea = true, Playermats = true } -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") val = 0 diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 4688efd5..cb851055 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,6 +1,6 @@ local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index aaee28aa..b1427e37 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -3,7 +3,7 @@ local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 136338ad..7cc27b65 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -127,7 +127,7 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - guidHandler = getObjectsWithTag("GUIDs")[1] + guidHandler = getObjectFromGUID("123456") DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) resetChaosTokenStatTracker() getModVersion() diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index c0f63408..12100390 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -3,7 +3,7 @@ local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 702c538d..89f7987b 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -1,8 +1,8 @@ do local MythosAreaApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getMythosArea() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MythosArea" }) end diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index 995fdbaf..e1249730 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -1,8 +1,8 @@ do local NavigationOverlayApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getNOHandler() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "NavigationOverlayHandler" }) end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 4a360321..cfdf7932 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -2,7 +2,7 @@ -- general setup --------------------------------------------------------- -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- Location connection directional options local BIDIRECTIONAL = 0 diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 54291f5f..a66bc39e 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,12 +1,13 @@ do local PlayAreaApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getPlayArea() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayArea" }) end local function getInvestigatorCounter() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "InvestigatorCounter" }) end diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 0339f519..36db9085 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -1,6 +1,5 @@ do local SoundCubeApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] -- this table links the name of a trigger effect to its index local soundIndices = { @@ -10,6 +9,7 @@ do } local function playTriggerEffect(index) + local guidHandler = getObjectFromGUID("123456") local SoundCube = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "SoundCube" }) SoundCube.AssetBundle.playTriggerEffect(index) end diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index 36680eff..3226cbbc 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -10,7 +10,7 @@ local countedVP = {} local highlightMissing = false local highlightCounted = false -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- button creation when loading the game function onLoad() diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index dc14fe0a..e15d8813 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -1,8 +1,8 @@ do local VictoryDisplayApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getVictoryDisplay() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }) end diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 91504bd6..67251e2a 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -3,8 +3,6 @@ do local playAreaApi = require("core/PlayAreaApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") - local guidHandler = getObjectsWithTag("GUIDs")[1] - local PLAYER_CARD_TOKEN_OFFSETS = { [1] = { Vector(0, 3, -0.2) @@ -337,6 +335,7 @@ do return end tokenTemplates = { } + local guidHandler = getObjectFromGUID("123456") local tokenSource = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSource" }) for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do local tokenName = tokenTemplate.Memo @@ -349,6 +348,7 @@ do if playerCardData ~= nil then return end + local guidHandler = getObjectFromGUID("123456") local dataHelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA') diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index 23cf7b8f..e82f3057 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,8 +1,8 @@ do local TokenSpawnTracker = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getSpawnTracker() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSpawnTracker" }) end diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index 4f67e09a..2b0ec255 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -123,8 +123,9 @@ do delay = delay + 0.5 end local lookPos - if TOUR_SCRIPT[cardIndex].objMemoData ~= nil then - local lookAtObj = Global.call("getObjectFromMemo", TOUR_SCRIPT[cardIndex].objMemoData) + if TOUR_SCRIPT[cardIndex].objReferenceData ~= nil then + local guidHandler = getObjectFromGUID("123456") + local lookAtObj = guidHandler.call("getObjectByOwnerAndType", TOUR_SCRIPT[cardIndex].objReferenceData) lookPos = lookAtObj.getPosition() lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0 -- Since camera isn't directly above the hook, changing the Y affects the visual position of diff --git a/src/core/tour/TourScript.ttslua b/src/core/tour/TourScript.ttslua index 203e7d05..6caf67e7 100644 --- a/src/core/tour/TourScript.ttslua +++ b/src/core/tour/TourScript.ttslua @@ -15,7 +15,7 @@ TOUR_SCRIPT = { { narrator = "Daisy", text = "If you're new to the game, the library here has everything you'll need. A little research can go a long way, and looking into old newspapers for the weird and unusual can yield some surprisingly helpful information.\n\nI put a few right there that might prove enlightening.", - objMemoData = { matColor = "Mythos", type = "RulesReference" }, + objReferenceData = { owner = "Mythos", type = "RulesReference" }, distanceFromObj = 20, position = "west", speakerSide = "right" @@ -23,7 +23,7 @@ TOUR_SCRIPT = { { narrator = "Mandy", text = "To survive what's coming you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here, and even find the newest version after an upgrade without changing the ID.\n\nNo need to publish all your decks, use 'Private' and you can see it. Just make sure to select 'Make your decks public' in ArkhamDB.", - objMemoData = { matColor = "Mythos", type = "DeckImporter" }, + objReferenceData = { owner = "Mythos", type = "DeckImporter" }, distanceFromObj = -5, position = "northwest", skipCentering = true, @@ -31,7 +31,7 @@ TOUR_SCRIPT = { { narrator = "Daniela", text = "I prefer the hands-on approach to building things, if you do too you can build a deck yourself.\n\nAll the cards you could ever need are here, laid out like a disassembled engine. Place the cards on the table, copy them for your deck, and you'll be ready for anything.", - objMemoData = { matColor = "Mythos", type = "PlayerCardPanel" }, + objReferenceData = { owner = "Mythos", type = "PlayerCardPanel" }, distanceFromObj = -7, position = "south", speakerSide = "right" @@ -39,7 +39,7 @@ TOUR_SCRIPT = { { narrator = "Finn", text = "Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\n\nJust remember - if it turns out to be too much for you, I was never here.", - objMemoData = { matColor = "Mythos", type = "CampaignThePathToCarcosa" }, + objReferenceData = { owner = "Mythos", type = "CampaignThePathToCarcosa" }, distanceFromObj = 20, position = "northwest", }, @@ -77,7 +77,7 @@ TOUR_SCRIPT = { { narrator = "Preston", text = "I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\n\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.", - objMemoData = { matColor = "Mythos", type = "ResourceTokenBag" }, + objReferenceData = { owner = "Mythos", type = "ResourceTokenBag" }, position = "north", skipCentering = true, speakerSide = "right" diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 8b0387f5..6178c6f1 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -1,8 +1,8 @@ do local AllCardsBagApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getAllCardsBag() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "AllCardsBag" }) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 586fa356..af2e2a4c 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -4,7 +4,7 @@ local navigationOverlayApi = require("core/NavigationOverlayApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- set true to enable debug logging and show Physics.cast() local DEBUG = false diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 30e4759f..6fb11f28 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -1,12 +1,23 @@ do local PlaymatApi = {} - local internal = {} + + -- Convenience function to look up a mat's object by color, or get all mats. + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@return array Table Single-element if only single playmat is requested + local function getMatForColor(matColor) + local guidHandler = getObjectFromGUID("123456") + if matColor == "All" then + return guidHandler.call("getObjectsByType", "Playermat") + else + return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } + end + end -- Returns the color of the closest playmat ---@param startPos Table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) local result, smallestDistance - for matColor, mat in pairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(getMatForColor("All")) do local distance = Vector.between(startPos, mat.getPosition()):magnitude() if smallestDistance == nil or distance < smallestDistance then smallestDistance = distance @@ -19,7 +30,7 @@ do -- Returns the color of the player's hand that is seated next to the playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getPlayerColor = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("playerColor") end end @@ -27,7 +38,7 @@ do -- Returns the color of the playmat that owns the playercolor's hand ---@param handColor String Color of the playmat PlaymatApi.getMatColor = function(handColor) - for matColor, mat in pairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(getMatForColor("All")) do local playerColor = mat.getVar("playerColor") if playerColor == handColor then return matColor @@ -38,7 +49,7 @@ do -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("isDES") end end @@ -46,7 +57,7 @@ do -- Returns the draw deck of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDrawDeck = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end @@ -55,7 +66,7 @@ do -- Returns the position of the discard pile of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.call("returnGlobalDiscardPosition") end end @@ -64,7 +75,7 @@ do ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.positionToWorld(localPos) end end @@ -72,7 +83,7 @@ do -- Returns the rotation of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getRotation() end end @@ -81,7 +92,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("doUpkeepFromHotkey", playerColor) end end @@ -89,7 +100,7 @@ do -- Returns the active investigator id ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("activeInvestigatorId") end end @@ -101,7 +112,7 @@ do ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end @@ -110,7 +121,7 @@ do ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end @@ -119,7 +130,7 @@ do ---@param showCounter Boolean Whether the clickable counter should be present or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end @@ -127,7 +138,7 @@ do -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("removeClues") end end @@ -136,7 +147,7 @@ do ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do count = count + mat.call("getClueCount", useClickableCounters) end return count @@ -148,7 +159,7 @@ do ---@param newValue Number Value to set the counter to ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier }) end end @@ -157,7 +168,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") ---@param type String Counter to target PlaymatApi.getCounterValue = function(matColor, type) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.call("getCounterValue", type) end end @@ -165,7 +176,7 @@ do -- resets the specified skill tracker to "1, 1, 1, 1" ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("resetSkillTracker") end end @@ -175,7 +186,7 @@ do ---@param filter Function Optional filter function (return true for desired objects) PlaymatApi.searchAroundPlaymat = function(matColor, filter) local objList = {} - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do table.insert(objList, obj) end @@ -186,29 +197,17 @@ do -- Discard a non-hidden card from the corresponding player's hand ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("doDiscardOne") end end -- Triggers the metadata sync for all playmats PlaymatApi.syncAllCustomizableCards = function() - for _, mat in pairs(internal.getMatForColor("All")) do + for _, mat in pairs(getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end - -- Convenience function to look up a mat's object by color, or get all mats. - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@return array Table Single-element if only single playmat is requested - internal.getMatForColor = function(matColor) - local guidHandler = getObjectsWithTag("GUIDs")[1] - if matColor == "All" then - return guidHandler.call("getObjectsByType", "Playermat") - else - return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } - end - end - return PlaymatApi end From 7bdb3d5347fef622561a923597cb6288402c4b84 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 8 Oct 2023 10:52:17 +0200 Subject: [PATCH 28/76] victory display api bugfix --- src/core/VictoryDisplayApi.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index e15d8813..32ee9878 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -16,7 +16,7 @@ do ---@param object Object Object that should be checked and potentially moved VictoryDisplayApi.placeCard = function(object) if object ~= nil and object.tag == "Card" then - getVictoryDisplay().call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }).call("placeCard", object) + getVictoryDisplay().call("placeCard", object) end end From 5cd37055a882eab2ace4d6b19c1665904ce94e6a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 9 Oct 2023 10:33:49 +0200 Subject: [PATCH 29/76] missing comma --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index e29aed88..26bf1852 100644 --- a/config.json +++ b/config.json @@ -199,7 +199,7 @@ "CampaignImporterExporter.334ee3", "TokenArranger.022907", "ChaosBagManager.023240", - "ArkhamSCE330-1092023-Page1.964222" + "ArkhamSCE330-1092023-Page1.964222", "SoulsofDarkness.a94e6b" ], "PlayArea": 1, From 7b0fd216efd085888fa15e9b70ffcb59cde921f3 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 10 Oct 2023 13:20:50 +0200 Subject: [PATCH 30/76] added investigator counter to handler --- src/core/GUIDReferenceHandler.ttslua | 1 + src/core/PlayArea.ttslua | 144 ++++++++++++++------------- src/core/PlayAreaApi.ttslua | 2 +- src/core/token/TokenManager.ttslua | 20 ++-- 4 files changed, 85 insertions(+), 82 deletions(-) diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua index 1a187064..c125f5d1 100644 --- a/src/core/GUIDReferenceHandler.ttslua +++ b/src/core/GUIDReferenceHandler.ttslua @@ -51,6 +51,7 @@ local GuidReferences = { DeckImporter = "a28140", DoomCounter = "85c4c6", DoomInPlayCounter = "652ff3", + InvestigatorCounter = "f182ee", MasterClueCounter = "4a3aa4", MythosArea = "9f334f", NavigationOverlayHandler = "797ede", diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index cfdf7932..9a284a59 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -2,61 +2,60 @@ -- general setup --------------------------------------------------------- -local guidHandler = getObjectFromGUID("123456") - -- Location connection directional options -local BIDIRECTIONAL = 0 -local ONE_WAY = 1 -local INCOMING_ONE_WAY = 2 +local BIDIRECTIONAL = 0 +local ONE_WAY = 1 +local INCOMING_ONE_WAY = 2 -- Connector draw parameters -local CONNECTION_THICKNESS = 0.015 +local CONNECTION_THICKNESS = 0.015 local DRAGGING_CONNECTION_THICKNESS = 0.15 -local DRAGGING_CONNECTION_COLOR = { 0.8, 0.8, 0.8, 1 } -local CONNECTION_COLOR = { 0.4, 0.4, 0.4, 1 } -local DIRECTIONAL_ARROW_DISTANCE = 3.5 -local ARROW_ARM_LENGTH = 0.9 -local ARROW_ANGLE = 25 +local DRAGGING_CONNECTION_COLOR = { 0.8, 0.8, 0.8, 1 } +local CONNECTION_COLOR = { 0.4, 0.4, 0.4, 1 } +local DIRECTIONAL_ARROW_DISTANCE = 3.5 +local ARROW_ARM_LENGTH = 0.9 +local ARROW_ANGLE = 25 -- Height to draw the connector lines, places them just above the table and always below cards -local CONNECTION_LINE_Y = 1.529 +local CONNECTION_LINE_Y = 1.529 -- we use this to turn off collision handling until onLoad() is complete -local collisionEnabled = false +local collisionEnabled = false -- used for recreating the link to a custom data helper after image change -customDataHelper = nil +customDataHelper = nil -local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/" +local DEFAULT_URL = +"http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/" -local SHIFT_OFFSETS = { +local SHIFT_OFFSETS = { left = { x = 0.00, y = 0, z = 7.67 }, right = { x = 0.00, y = 0, z = -7.67 }, up = { x = 6.54, y = 0, z = 0.00 }, down = { x = -6.54, y = 0, z = 0.00 } } -local SHIFT_EXCLUSION = { +local SHIFT_EXCLUSION = { ["b7b45b"] = true, ["f182ee"] = true, ["721ba2"] = true } -local LOC_LINK_EXCLUDE_SCENARIOS = { +local LOC_LINK_EXCLUDE_SCENARIOS = { ["The Witching Hour"] = true, ["The Heart of Madness"] = true } -local tokenManager = require("core/token/TokenManager") +local tokenManager = require("core/token/TokenManager") -local clueData = {} -local spawnedLocationGUIDs = {} -local locations = {} -local locationConnections = {} -local draggingGuids = {} +local clueData = {} +local spawnedLocationGUIDs = {} +local locations = {} +local locationConnections = {} +local draggingGuids = {} local locationData local currentScenario -local missingData = {} -local countedVP = {} +local missingData = {} +local countedVP = {} --------------------------------------------------------- -- general code @@ -71,8 +70,8 @@ end function onLoad(saveState) -- records locations we have spawned clues for - local save = JSON.decode(saveState) or { } - locations = save.trackedLocations or { } + local save = JSON.decode(saveState) or {} + locations = save.trackedLocations or {} currentScenario = save.currentScenario self.interactable = false @@ -93,13 +92,13 @@ function updateSurface(newURL) local customInfo = self.getCustomObject() if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then - customInfo.image = newURL - broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) + customInfo.image = newURL + broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) else - customInfo.image = DEFAULT_URL - broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) + customInfo.image = DEFAULT_URL + broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) end - + self.setCustomObject(customInfo) local guid = nil @@ -108,7 +107,7 @@ function updateSurface(newURL) self.reload() if guid ~= nil then - Wait.time(function() updateLocations({ guid }) end, 1) + Wait.time(function() updateLocations({ guid }) end, 1) end end @@ -129,12 +128,14 @@ function onCollisionEnter(collisionInfo) if shouldSpawnTokens(card) then tokenManager.spawnForCard(card) end + -- 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 if draggingGuids[card.getGUID()] ~= nil then card.setVectorLines(nil) draggingGuids[card.getGUID()] = nil end + maybeTrackLocation(card) end @@ -167,20 +168,20 @@ function onObjectPickUp(player, object) -- should be tracking if showLocationLinks() and isInPlayArea(object) and object.getGMNotes() ~= nil and object.getGMNotes() ~= "" then local pickedUpGuid = object.getGUID() - local metadata = JSON.decode(object.getGMNotes()) or { } + local metadata = JSON.decode(object.getGMNotes()) or {} if metadata.type == "Location" then -- onCollisionExit sometimes comes 1 frame after onObjectPickUp (rather than before it or in -- the same frame). This causes a mismatch in the data between dragging the on-table, and -- that one frame draws connectors on the card which then show up as shadows for snap points. -- Waiting ensures we always do thing in the expected Exit->PickUp order Wait.frames(function() - if object.is_face_down then - draggingGuids[pickedUpGuid] = metadata.locationBack - else - draggingGuids[pickedUpGuid] = metadata.locationFront - end - rebuildConnectionList() - end, 2) + if object.is_face_down then + draggingGuids[pickedUpGuid] = metadata.locationBack + else + draggingGuids[pickedUpGuid] = metadata.locationFront + end + rebuildConnectionList() + end, 2) end end end @@ -273,11 +274,11 @@ end -- drawBaseConnections() function rebuildConnectionList() if not showLocationLinks() then - locationConnections = { } + locationConnections = {} return end - local iconCardList = { } + local iconCardList = {} -- Build a list of cards with each icon as their location ID for cardId, metadata in pairs(draggingGuids) do @@ -288,7 +289,7 @@ function rebuildConnectionList() end -- Pair up all the icons - locationConnections = { } + locationConnections = {} for cardId, metadata in pairs(draggingGuids) do buildConnection(cardId, iconCardList, metadata) end @@ -307,7 +308,7 @@ function buildLocListByIcon(cardId, iconCardList, locData) if locData ~= nil and locData.icons ~= nil then for icon in string.gmatch(locData.icons, "%a+") do if iconCardList[icon] == nil then - iconCardList[icon] = { } + iconCardList[icon] = {} end table.insert(iconCardList[icon], cardId) end @@ -321,19 +322,19 @@ end ---@param locData Table A table containing the metadata for the card (for the correct side) function buildConnection(cardId, iconCardList, locData) if locData ~= nil and locData.connections ~= nil then - locationConnections[cardId] = { } + locationConnections[cardId] = {} for icon in string.gmatch(locData.connections, "%a+") do if iconCardList[icon] ~= nil then for _, connectedGuid in ipairs(iconCardList[icon]) do -- If the reciprocal exists, convert it to BiDi, otherwise add as a one-way if locationConnections[connectedGuid] ~= nil and (locationConnections[connectedGuid][cardId] == ONE_WAY - or locationConnections[connectedGuid][cardId] == BIDIRECTIONAL) then + or locationConnections[connectedGuid][cardId] == BIDIRECTIONAL) then locationConnections[connectedGuid][cardId] = BIDIRECTIONAL locationConnections[cardId][connectedGuid] = nil else if locationConnections[connectedGuid] == nil then - locationConnections[connectedGuid] = { } + locationConnections[connectedGuid] = {} end locationConnections[cardId][connectedGuid] = ONE_WAY locationConnections[connectedGuid][cardId] = INCOMING_ONE_WAY @@ -348,10 +349,10 @@ end -- Constructed vectors will be set to the playmat function drawBaseConnections() if not showLocationLinks() then - locationConnections = { } + locationConnections = {} return end - local cardConnectionLines = { } + local cardConnectionLines = {} for originGuid, targetGuids in pairs(locationConnections) do -- Objects should reliably exist at this point, but since this can be called during onUpdate the @@ -380,8 +381,8 @@ function drawDraggingConnections() if not showLocationLinks() then return end - local cardConnectionLines = { } - local ownedVectors = { } + local cardConnectionLines = {} + local ownedVectors = {} for originGuid, _ in pairs(draggingGuids) do targetGuids = locationConnections[originGuid] @@ -389,7 +390,7 @@ function drawDraggingConnections() -- object checks are conservative just to make sure. local origin = getObjectFromGUID(originGuid) if draggingGuids[originGuid] and origin ~= nil and targetGuids ~= nil then - ownedVectors[originGuid] = { } + ownedVectors[originGuid] = {} for targetGuid, direction in pairs(targetGuids) do local target = getObjectFromGUID(targetGuid) if target != nil then @@ -427,9 +428,9 @@ function addBidirectionalVector(card1, card2, vectorOwner, lines) local pos2 = vectorOwner.positionToLocal(cardPos2) table.insert(lines, { - points = { pos1, pos2 }, - color = vectorOwner == self and CONNECTION_COLOR or DRAGGING_CONNECTION_COLOR, - thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS, + points = { pos1, pos2 }, + color = vectorOwner == self and CONNECTION_COLOR or DRAGGING_CONNECTION_COLOR, + thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS, }) end @@ -451,11 +452,13 @@ function addOneWayVector(origin, target, vectorOwner, lines) -- Calculate card distance to be closer for horizontal positions than vertical, since cards are -- taller than they are wide local heading = Vector(originPos):sub(targetPos):heading("y") - local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + DIRECTIONAL_ARROW_DISTANCE * 0.3 * math.abs(math.sin(math.rad(heading))) + local distanceFromCard = DIRECTIONAL_ARROW_DISTANCE * 0.7 + + 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 -- 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, ARROW_ARM_LENGTH / 2) + local midpoint = Vector(originPos):add(targetPos):scale(Vector(0.5, 0.5, 0.5)):moveTowards(targetPos, + 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) @@ -474,14 +477,16 @@ end --- 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 function addArrowLines(arrowheadPos, originPos, vectorOwner, lines) - local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", -1 * ARROW_ANGLE):add(arrowheadPos) - local arrowArm2 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", ARROW_ANGLE):add(arrowheadPos) + local arrowArm1 = Vector(arrowheadPos):moveTowards(originPos, ARROW_ARM_LENGTH):sub(arrowheadPos):rotateOver("y", + -1 * 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 arm1 = vectorOwner.positionToLocal(arrowArm1) local arm2 = vectorOwner.positionToLocal(arrowArm2) table.insert(lines, { - points = { arm1, head, arm2}, + points = { arm1, head, arm2 }, color = vectorOwner == self and CONNECTION_COLOR or DRAGGING_CONNECTION_COLOR, thickness = vectorOwner == self and CONNECTION_THICKNESS or DRAGGING_CONNECTION_THICKNESS, }) @@ -508,6 +513,7 @@ function shiftContentsRight(playerColor) end function shiftContents(playerColor, direction) + local guidHandler = getObjectFromGUID("123456") local zone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) if not zone then broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") @@ -530,8 +536,8 @@ function isInPlayArea(object) local bounds = self.getBounds() local position = object.getPosition() -- Corners are arbitrary since it's all global - c1 goes down both axes, c2 goes up - local c1 = { x = bounds.center.x - bounds.size.x / 2, z = bounds.center.z - bounds.size.z / 2} - local c2 = { x = bounds.center.x + bounds.size.x / 2, z = bounds.center.z + bounds.size.z / 2} + local c1 = { x = bounds.center.x - bounds.size.x / 2, z = bounds.center.z - bounds.size.z / 2 } + local c2 = { x = bounds.center.x + bounds.size.x / 2, z = bounds.center.z + bounds.size.z / 2 } return position.x > c1.x and position.x < c2.x and position.z > c1.z and position.z < c2.z end @@ -582,7 +588,7 @@ function countVP() local cardVP = tonumber(metadata.victory) or 0 if cardVP ~= 0 and not cardHasClues(cardId) then totalVP = totalVP + cardVP - if cardVP >0 then + if cardVP > 0 then table.insert(countedVP, getObjectFromGUID(cardId)) end end @@ -651,8 +657,8 @@ end -- rebuilds local snap points (could be useful in the future again) function buildSnaps() - local upperleft = { x = 1.53, z = -1.09} - local lowerright = {x = -1.53, z = 1.55} + local upperleft = { x = 1.53, z = -1.09 } + local lowerright = { x = -1.53, z = 1.55 } local snaps = {} -- creates 81 snap points, for uneven rows + columns it makes a rotation snap point @@ -666,7 +672,7 @@ function buildSnaps() -- enable rotation snaps for uneven rows / columns if (i % 2 ~= 0) and (j % 2 ~= 0) then - snap.rotation = {0, 0, 0} + snap.rotation = { 0, 0, 0 } snap.rotation_snap = true end @@ -678,6 +684,6 @@ end -- utility function function round(num, numDecimalPlaces) - local mult = 10^(numDecimalPlaces or 0) + local mult = 10 ^ (numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index a66bc39e..e903e2c8 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -14,7 +14,7 @@ do -- Returns the current value of the investigator counter from the playmat ---@return Integer. Number of investigators currently set on the counter PlayAreaApi.getInvestigatorCount = function() - getInvestigatorCounter().getVar("val") + return getInvestigatorCounter().getVar("val") end -- Updates the current value of the investigator counter from the playmat diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 192d7aad..297c7061 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -365,18 +365,16 @@ do if uses == nil then return end -- go through tokens to spawn - local type, token, tokenCount + local tokenCount for i, useInfo in ipairs(uses) do - type = useInfo.type - token = useInfo.token - tokenCount = (useInfo.count or 0) - + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount() - if extraUses ~= nil and extraUses[type] ~= nil then - tokenCount = tokenCount + extraUses[type] + tokenCount = (useInfo.count or 0) + (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount() + if extraUses ~= nil and extraUses[useInfo.type] ~= nil then + tokenCount = tokenCount + extraUses[useInfo.type] end -- Shift each spawned group after the first down so they don't pile on each other - TokenManager.spawnTokenGroup(card, token, tokenCount, (i - 1) * 0.8, type) + TokenManager.spawnTokenGroup(card, useInfo.token, tokenCount, (i - 1) * 0.8, useInfo.type) end + tokenSpawnTrackerApi.markTokensSpawned(card.getGUID()) end @@ -400,9 +398,8 @@ do ---@param playerData Table Player card data structure retrieved from the DataHelper. Should be -- the right data for this card. internal.spawnPlayerCardTokensFromDataHelper = function(card, playerData) - token = playerData.tokenType - tokenCount = playerData.tokenCount - --log("Spawning data helper tokens for "..card.getName()..'['..card.getDescription()..']: '..tokenCount.."x "..token) + local token = playerData.tokenType + local tokenCount = playerData.tokenCount TokenManager.spawnTokenGroup(card, token, tokenCount) tokenSpawnTrackerApi.markTokensSpawned(card.getGUID()) end @@ -435,7 +432,6 @@ do return 0 end - --log(card.getName() .. ' : ' .. locationData.type .. ' : ' .. locationData.value .. ' : ' .. locationData.clueSide) if ((card.is_face_down and locationData.clueSide == 'back') or (not card.is_face_down and locationData.clueSide == 'front')) then if locationData.type == 'fixed' then From 34fa7ea7e8b4797cef2a26c1aeb15b51b96d9093 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 11 Oct 2023 13:26:36 +0200 Subject: [PATCH 31/76] removal of outdated code --- src/core/Global.ttslua | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 9b69cd6c..53d5aba9 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -165,23 +165,6 @@ function tryObjectEnterContainer(container, object) return true end --- gets all objects that match the provided matcolor ----@param matColor String Color of the playermat ----@return objList Table Table of type-object pairs -function getObjectsForMatColor(matColor) - local objList = {} - for _, obj in ipairs(getObjects()) do - local memo = obj.getMemo() - if memo and memo:sub(1, 1) == "{" then - local decoded = JSON.decode(memo) or {} - if decoded.matColor == matColor then - objList[decoded.type] = obj - end - end - end - return objList -end - --------------------------------------------------------- -- chaos token drawing --------------------------------------------------------- @@ -310,10 +293,8 @@ function handleStatTrackerClick(_, _, isRightClick) playerColor = "White" playerName = "Overall" else - -- get mat color from memo - local mat = getObjectFromGUID(key) - local decoded = JSON.decode(mat.getMemo()) - local matColor = decoded.matColor + -- get mat color + local matColor = playmatApi.getMatColorByPosition(getObjectFromGUID(key).getPosition()) playerColor = playmatApi.getPlayerColor(matColor) playerName = Player[playerColor].steam_name or playerColor @@ -889,7 +870,8 @@ function applyOptionPanelChange(id, state) optionPanel[id] = state -- update master clue counter - getObjectFromMemo({matColor = "Mythos", type = "MasterClueCounter"}).setVar("useClickableCounters", state) + local counter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MasterClueCounter" }) + counter.setVar("useClickableCounters", state) -- option: Play area snap tags elseif id == "playAreaSnapTags" then From edc2cc6fab02c08c1c07baa58b18cdab8266300e Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 11 Oct 2023 19:39:05 +0200 Subject: [PATCH 32/76] mythos area bugfix --- src/core/Global.ttslua | 96 ++++++++++++++++++----------------- src/core/MythosAreaApi.ttslua | 2 +- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 53d5aba9..bb2ba922 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -12,8 +12,8 @@ local tokenManager = require("core/token/TokenManager") -- general setup --------------------------------------------------------- -ENCOUNTER_DECK_POS = {-3.93, 1, 5.76} -ENCOUNTER_DECK_DISCARD_POSITION = {-3.85, 1, 10.38} +ENCOUNTER_DECK_POS = { -3.93, 1, 5.76 } +ENCOUNTER_DECK_DISCARD_POSITION = { -3.85, 1, 10.38 } -- GUIDs that will not be interactable (e.g. parts of the table) local NOT_INTERACTABLE = { @@ -36,7 +36,7 @@ chaosTokens = {} local chaosTokensLastMat = nil local bagSearchers = {} -local MAT_COLORS = {"White", "Orange", "Green", "Red"} +local MAT_COLORS = { "White", "Orange", "Green", "Red" } local hideTitleSplashWaitFunctionId = nil -- online functionality related variables @@ -113,7 +113,12 @@ local tokenDrawingStats = { --------------------------------------------------------- -- saving state of optionPanel to restore later -function onSave() return JSON.encode({ optionPanel = optionPanel, acknowledgedUpgradeVersions = acknowledgedUpgradeVersions }) end +function onSave() + return JSON.encode({ + optionPanel = optionPanel, + acknowledgedUpgradeVersions = acknowledgedUpgradeVersions + }) +end function onLoad(savedData) if savedData then @@ -282,8 +287,8 @@ function handleStatTrackerClick(_, _, isRightClick) if isRightClick then resetChaosTokenStatTracker() else - local squidKing = "Nobody" - local maxSquid = 0 + local squidKing = "Nobody" + local maxSquid = 0 local foundAnyStats = false for key, personalStats in pairs(tokenDrawingStats) do @@ -315,8 +320,8 @@ function handleStatTrackerClick(_, _, isRightClick) if totalCount > 0 then foundAnyStats = true printToAll("------------------------------") - printToAll(playerName .. " Stats", playerColor) - + printToAll(playerName .. " Stats", playerColor) + for tokenName, value in pairs(personalStats) do if value ~= 0 then printToAll(tokenName .. ': ' .. tostring(value)) @@ -329,7 +334,7 @@ function handleStatTrackerClick(_, _, isRightClick) -- detect if any player drew tokens if foundAnyStats then printToAll("------------------------------") - printToAll(squidKing .. " is an auto-fail magnet.", {255, 0, 0}) + printToAll(squidKing .. " is an auto-fail magnet.", { 255, 0, 0 }) else printToAll("No tokens have been drawn yet.", "Yellow") end @@ -358,11 +363,11 @@ function createSetupButtons(args) if data ~= nil then local buttonParameters = {} buttonParameters.function_owner = args.object - buttonParameters.position = {0, 0.1, -0.15} - buttonParameters.scale = {0.47, 1, 0.47} + buttonParameters.position = { 0, 0.1, -0.15 } + buttonParameters.scale = { 0.47, 1, 0.47 } buttonParameters.height = 200 buttonParameters.width = 1150 - buttonParameters.color = {0.87, 0.8, 0.7} + buttonParameters.color = { 0.87, 0.8, 0.7 } if data.easy ~= nil then buttonParameters.label = "Easy" @@ -490,7 +495,6 @@ function getChaosBagState() end return tokens - end -- respawns the chaos bag with a new state of tokens @@ -519,7 +523,7 @@ function setChaosBagState(tokenList) -- overwrite chaos bag content and respawn it chaosbagData.ContainedObjects = containedObjects chaosbag.destruct() - spawnObjectData({data = chaosbagData}) + spawnObjectData({ data = chaosbagData }) -- remove tokens that are still in play for _, token in pairs(chaosTokens) do @@ -548,7 +552,7 @@ function spawnChaosToken(id) type = 'Custom_Tile', position = { 0.49, 3, 0 }, scale = { 0.81, 1.0, 0.81 }, - rotation = {0, 270, 0}, + rotation = { 0, 270, 0 }, callback_function = function(obj) obj.setName(ID_URL_MAP[id].name) chaosbag.putObject(obj) @@ -598,7 +602,7 @@ function emptyChaosBag() local chaosbag = findChaosBag() for _, object in ipairs(chaosbag.getObjects()) do - chaosbag.takeObject({callback_function = function(item) item.destruct() end}) + chaosbag.takeObject({ callback_function = function(item) item.destruct() end }) end end @@ -623,7 +627,7 @@ end function onClick_select(player, params) params = JSON.decode(urldecode(params)) local url = SOURCE_REPO .. '/' .. params.url - local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end ) + local request = WebRequest.get(url, function(request) complete_obj_download(request, params) end) requestObj = request startLuaCoroutine(Global, 'downloadCoroutine') end @@ -675,7 +679,8 @@ function update_list(objects) for _, v in ipairs(objects) do local s = JSON.encode(v); table.insert(update_children.children, - { tag = 'Text', + { + tag = 'Text', value = v.name, attributes = { onClick = 'onClick_select(' .. urlencode(JSON.encode(v)) .. ')', alignment = 'MiddleLeft' } }) @@ -709,24 +714,24 @@ function complete_obj_download(request, params) print('error: ' .. request.error) else if pcall(function() - local replaced_object - pcall(function() - if params.replace then - replaced_object = getObjectFromGUID(params.replace) - end - end) - local json = request.text - if replaced_object then - local pos = replaced_object.getPosition() - local rot = replaced_object.getRotation() - destroyObject(replaced_object) - Wait.frames(function() - spawnObjectJSON({json = json, position = pos, rotation = rot}) - end, 1) - else - spawnObjectJSON({json = json}) - end - end) then + local replaced_object + pcall(function() + if params.replace then + replaced_object = getObjectFromGUID(params.replace) + end + end) + local json = request.text + if replaced_object then + local pos = replaced_object.getPosition() + local rot = replaced_object.getRotation() + destroyObject(replaced_object) + Wait.frames(function() + spawnObjectJSON({ json = json, position = pos, rotation = rot }) + end, 1) + else + spawnObjectJSON({ json = json }) + end + end) then print('Object loaded.') else print('Error loading object.') @@ -749,7 +754,7 @@ function completed_list_update(request) print('error: ' .. request.error) else local json_response = nil - if pcall(function () json_response = JSON.decode(request.text) end) then + if pcall(function() json_response = JSON.decode(request.text) end) then library = json_response update_window_content(UI.getValue('title')) else @@ -774,13 +779,13 @@ end function urlencode(str) local str = string.gsub(str, "([^A-Za-z0-9-_.~])", - function (c) return string.format("%%%02X", string.byte(c)) end) + function(c) return string.format("%%%02X", string.byte(c)) end) return str end function urldecode(str) local str = string.gsub(str, "%%(%x%x)", - function (h) return string.char(tonumber(h, 16)) end) + function(h) return string.char(tonumber(h, 16)) end) return str end @@ -950,7 +955,7 @@ function spawnHelperObject(name, position, rotation) return end - local spawnTable = {position = position} + local spawnTable = { position = position } -- only overrride rotation if there is one provided (object's rotation used instead) if rotation then @@ -1043,7 +1048,6 @@ end -- splash scenario title on setup function titleSplash(scenarioName) if optionPanel['showTitleSplash'] then - -- if there's any ongoing title being displayed, hide it and cancel the waiting function if hideTitleSplashWaitFunctionId then Wait.stop(hideTitleSplashWaitFunctionId) @@ -1085,7 +1089,7 @@ function compareVersion(request) -- stop here if on latest version if MOD_VERSION == modMeta["latestVersion"] then return end - + -- stop here if "don't show again" was clicked for this version before if acknowledgedUpgradeVersions[modMeta["latestVersion"]] then return end @@ -1107,12 +1111,12 @@ function updateNotificationLoading() highlightText = highlightText .. "\n• " .. entry end end - + -- update the XML UI - UI.setValue("notificationHeader", "New version available: ".. modMeta["latestVersion"]) + UI.setValue("notificationHeader", "New version available: " .. modMeta["latestVersion"]) UI.setValue("releaseHighlightText", highlightText) - UI.setAttribute("highlightRow", "preferredHeight", 20*#highlights) - UI.setAttribute("updateNotification", "height", 20*#highlights + 125) + UI.setAttribute("highlightRow", "preferredHeight", 20 * #highlights) + UI.setAttribute("updateNotification", "height", 20 * #highlights + 125) end -- triggered by clicking on the Finn Icon diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 89f7987b..e9908ab7 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -8,7 +8,7 @@ do -- returns the chaos token metadata (if provided through scenario reference card) MythosAreaApi.returnTokenData = function() - getMythosArea().call("returnTokenData") + return getMythosArea().call("returnTokenData") end -- draw an encounter card to the requested position/rotation From 4439add1063d0b760951f9199ffdc5d028b8cbde Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 11 Oct 2023 19:58:42 +0200 Subject: [PATCH 33/76] shortsupply outdated function fix --- src/playercards/cards/ShortSupply.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playercards/cards/ShortSupply.ttslua b/src/playercards/cards/ShortSupply.ttslua index f01e6204..102696ae 100644 --- a/src/playercards/cards/ShortSupply.ttslua +++ b/src/playercards/cards/ShortSupply.ttslua @@ -21,7 +21,7 @@ function shortSupply(color) if drawDeck == nil then broadcastToColor("Deck not found!", color, "Yellow") return - elseif drawDeck.tag ~= "Deck" then + elseif drawDeck.type ~= "Deck" then broadcastToColor("Deck only contains a single card!", color, "Yellow") return end From 2cee7df57fc38fe6a9f68d103d7d193c8bcbdfcf Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 11 Oct 2023 20:37:59 +0200 Subject: [PATCH 34/76] download window QoL --- src/core/Global.ttslua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 39394941..699832bf 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -141,6 +141,7 @@ function onLoad(savedData) resetChaosTokenStatTracker() getModVersion() + onClick_refreshList() math.randomseed(os.time()) end @@ -724,9 +725,10 @@ function complete_obj_download(request, params) if replaced_object then local pos = replaced_object.getPosition() local rot = replaced_object.getRotation() + local scale = replaced_object.getScale() destroyObject(replaced_object) Wait.frames(function() - spawnObjectJSON({json = json, position = pos, rotation = rot}) + spawnObjectJSON({ json = json, position = pos, rotation = rot, scale = scale }) end, 1) else spawnObjectJSON({json = json}) From 04f337482a34623bb49b8b94f87f3c803364b89a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 13 Oct 2023 13:01:43 +0200 Subject: [PATCH 35/76] revamped window with tabs --- src/core/Global.ttslua | 186 ++++++++++++++++++++++++----------------- xml/BottomBar.xml | 41 +++++++++ xml/DownloadWindow.xml | 83 ++++++++++++++++++ xml/Global.xml | 108 +----------------------- 4 files changed, 237 insertions(+), 181 deletions(-) create mode 100644 xml/BottomBar.xml create mode 100644 xml/DownloadWindow.xml diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 699832bf..fb2682ec 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -44,6 +44,8 @@ local hideTitleSplashWaitFunctionId = nil local MOD_VERSION = "3.3.0" local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' local library, requestObj, modMeta, notificationVisible +local downloadWindowVisible = false +local optionPanelVisible = false local acknowledgedUpgradeVersions = {} -- optionPanel data @@ -141,8 +143,10 @@ function onLoad(savedData) resetChaosTokenStatTracker() getModVersion() - onClick_refreshList() math.randomseed(os.time()) + + -- initialization of loadable objects library + requestObj = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) end -- Event hook for any object search. When chaos tokens are manipulated while the chaos bag @@ -620,66 +624,110 @@ end -- Content Importing and XML functions --------------------------------------------------------- -function onClick_refreshList() - local request = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) - requestObj = request - startLuaCoroutine(Global, 'downloadCoroutine') +-- forwards the requested content type to the update function +---@param player LuaPlayer Player that triggered this +---@param contentToShow String Name of the content type to show +function onClick_tab(player, contentToShow) + update_list(contentToShow) end +-- click function for the items in the download window function onClick_select(player, params) params = JSON.decode(urldecode(params)) local url = SOURCE_REPO .. '/' .. params.url - local request = WebRequest.get(url, function (request) complete_obj_download(request, params) end ) - requestObj = request + requestObj = WebRequest.get(url, function (request) complete_obj_download(request, params) end ) startLuaCoroutine(Global, 'downloadCoroutine') end -function onClick_load() - UI.show('progress_display') - UI.hide('load_button') -end - -function onClick_toggleUi(player, title) - if title == "Navigation Overlay" then - navigationOverlayApi.cycleVisibility(player.color) - return - end - - UI.hide('optionPanel') - UI.hide('load_ui') - - -- when same button is clicked or close window button is pressed, don't open UI - if UI.getValue('title') ~= title and title ~= 'Hidden' then - UI.setValue('title', title) - - if title == "Options" then - UI.show('optionPanel') - else - update_window_content(title) - UI.show('load_ui') - end - else - UI.setValue('title', "Hidden") - end -end - function downloadCoroutine() while requestObj do UI.setAttribute('download_progress', 'percentage', requestObj.download_progress * 100) coroutine.yield(0) end + UI.setAttribute('download_progress', 'percentage', 100) return 1 end -function update_list(objects) +-- toggles the visibility of the respective UI +---@param player LuaPlayer Player that triggered this +---@param title String Name of the UI to toggle +function onClick_toggleUi(player, title) + if title == "Navigation Overlay" then + navigationOverlayApi.cycleVisibility(player.color) + elseif title == "Downloadable Content" then + if downloadWindowVisible then + UI.hide('downloadWindow') + else + UI.show('downloadWindow') + end + downloadWindowVisible = not downloadWindowVisible + elseif title == "Options" then + if optionPanelVisible then + UI.hide('optionPanel') + else + UI.show('optionPanel') + end + optionPanelVisible = not optionPanelVisible + end +end + +-- formats the json response from the webrequest into a key-value lua table +-- strips the prefix from the community content items +function formatLibrary(json_response) + library = {} + library["campaigns"] = json_response.campaigns + library["scenarios"] = json_response.scenarios + library["extras"] = json_response.extras + library["fanmadeCampaigns"] = {} + library["fanmadeScenarios"] = {} + library["fanmadePlayerCards"] = {} + + for _, item in ipairs(json_response.community) do + local identifier = nil + for str in string.gmatch(item.name, "([^:]+)") do + if not identifier then + -- grab the first part to know the content type + identifier = str + else + -- update the name without the content type + item.name = str + break + end + end + + if identifier == "Fan Investigators" then + table.insert(library["fanmadePlayerCards"], item) + elseif identifier == "Fan Campaign" then + table.insert(library["fanmadeCampaigns"], item) + elseif identifier == "Fan Scenario" then + table.insert(library["fanmadeScenarios"], item) + end + end +end + +-- updates the window content to the requested content +---@param contentToShow String Type of content to show +function update_list(contentToShow) + if not library then return end + local ui = UI.getXmlTable() + + -- set title according to type + local cleanName = { + campaigns = "Campaigns", + scenarios = "Scenarios", + fanmadeCampaigns = "Fan-Made Campaigns", + fanmadePlayerCards = "Fan-Made Player Cards", + fanmadeScenarios = "Fan-Made Scenarios" + } + local titleText = find_tag_with_id(ui, "title") + titleText.value = "Downloable Content: " .. cleanName[contentToShow] + local update_height = find_tag_with_id(ui, 'ui_update_height') local update_children = find_tag_with_id(update_height.children, 'ui_update_point') - update_children.children = {} - for _, v in ipairs(objects) do - local s = JSON.encode(v); + for _, v in ipairs(library[contentToShow]) do table.insert(update_children.children, { tag = 'Text', value = v.name, @@ -691,47 +739,35 @@ function update_list(objects) UI.setXmlTable(ui) end -function update_window_content(new_title) - if not library then return end - - if new_title == 'Campaigns' then - update_list(library.campaigns) - elseif new_title == 'Standalone Scenarios' then - update_list(library.scenarios) - elseif new_title == 'Investigators' then - update_list(library.investigators) - elseif new_title == 'Community Content' then - update_list(library.community) - elseif new_title == 'Extras' then - update_list(library.extras) - else - update_list({}) - end -end - +-- called after the webrequest of downloading an item +-- deletes the placeholder and spawns the downloaded item function complete_obj_download(request, params) assert(request.is_done) if request.is_error or request.response_code ~= 200 then print('error: ' .. request.error) else if pcall(function() - local replaced_object + local replacedObject pcall(function() if params.replace then - replaced_object = getObjectFromGUID(params.replace) + replacedObject = getObjectFromGUID(params.replace) end end) - local json = request.text - if replaced_object then - local pos = replaced_object.getPosition() - local rot = replaced_object.getRotation() - local scale = replaced_object.getScale() - destroyObject(replaced_object) + if replacedObject then + local pos = replacedObject.getPosition() + local rot = replacedObject.getRotation() + local scale = replacedObject.getScale() + destroyObject(replacedObject) Wait.frames(function() - spawnObjectJSON({ json = json, position = pos, rotation = rot, scale = scale }) + spawnObjectJSON({ + json = request.text, + position = pos, + rotation = rot, + scale = scale + }) end, 1) else - spawnObjectJSON({json = json}) + spawnObjectJSON({ json = request.text }) end end) then print('Object loaded.') @@ -739,17 +775,16 @@ function complete_obj_download(request, params) print('Error loading object.') end end - requestObj = nil - UI.setAttribute('download_progress', 'percentage', 100) end -- the download button on the placeholder objects calls this to directly initiate a download --- params is a table with url and guid of replacement object, which happens to match what onClick_select wants +---@param params Table contains url and guid of replacement object, which happens to match what onClick_select wants function placeholder_download(params) onClick_select(nil, JSON.encode(params)) end +-- downloading of the library file function completed_list_update(request) assert(request.is_done) if request.is_error or request.response_code ~= 200 then @@ -757,17 +792,18 @@ function completed_list_update(request) else local json_response = nil if pcall(function () json_response = JSON.decode(request.text) end) then - library = json_response - update_window_content(UI.getValue('title')) + formatLibrary(json_response) + update_list("campaigns") else print('error parsing downloaded library') end end - requestObj = nil - UI.setAttribute('download_progress', 'percentage', 100) end +-- loops through an XML table and returns the specified object +---@param ui Table XmlTable (get this via getXmlTable) +---@param id String Id of the object to return function find_tag_with_id(ui, id) for _, obj in ipairs(ui) do if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end diff --git a/xml/BottomBar.xml b/xml/BottomBar.xml new file mode 100644 index 00000000..f7204b91 --- /dev/null +++ b/xml/BottomBar.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + Please refresh to see available items. + + + + + + + + + \ No newline at end of file diff --git a/xml/Global.xml b/xml/Global.xml index 5d9fb47d..595c3b42 100644 --- a/xml/Global.xml +++ b/xml/Global.xml @@ -3,114 +3,10 @@ - - - - - - - - + + From 52de8be402eb2baf35002a50c14e252d46099a53 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 13 Oct 2023 14:52:31 +0200 Subject: [PATCH 36/76] moved files into subfolder --- config.json | 2 +- xml/Global.xml | 13 ------------- xml/{ => Global}/BottomBar.xml | 0 xml/{ => Global}/DownloadWindow.xml | 0 xml/Global/Global.xml | 12 ++++++++++++ xml/{ => Global}/NavigationOverlay.xml | 0 xml/{ => Global}/OptionPanel.xml | 0 xml/{ => Global}/TitleSplash.xml | 0 xml/{ => Global}/UpdateNotification.xml | 0 9 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 xml/Global.xml rename xml/{ => Global}/BottomBar.xml (100%) rename xml/{ => Global}/DownloadWindow.xml (100%) create mode 100644 xml/Global/Global.xml rename xml/{ => Global}/NavigationOverlay.xml (100%) rename xml/{ => Global}/OptionPanel.xml (100%) rename xml/{ => Global}/TitleSplash.xml (100%) rename xml/{ => Global}/UpdateNotification.xml (100%) diff --git a/config.json b/config.json index 45015cf7..bf3cf147 100644 --- a/config.json +++ b/config.json @@ -218,5 +218,5 @@ "Tags": [], "Turns_path": "Turns.json", "VersionNumber": "v13.2.2", - "XmlUI": "\u003cInclude src=\"Global.xml\"/\u003e" + "XmlUI": "\u003cInclude src=\"Global/Global.xml\"/\u003e" } diff --git a/xml/Global.xml b/xml/Global.xml deleted file mode 100644 index 595c3b42..00000000 --- a/xml/Global.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/xml/BottomBar.xml b/xml/Global/BottomBar.xml similarity index 100% rename from xml/BottomBar.xml rename to xml/Global/BottomBar.xml diff --git a/xml/DownloadWindow.xml b/xml/Global/DownloadWindow.xml similarity index 100% rename from xml/DownloadWindow.xml rename to xml/Global/DownloadWindow.xml diff --git a/xml/Global/Global.xml b/xml/Global/Global.xml new file mode 100644 index 00000000..6f6f0d4d --- /dev/null +++ b/xml/Global/Global.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/xml/NavigationOverlay.xml b/xml/Global/NavigationOverlay.xml similarity index 100% rename from xml/NavigationOverlay.xml rename to xml/Global/NavigationOverlay.xml diff --git a/xml/OptionPanel.xml b/xml/Global/OptionPanel.xml similarity index 100% rename from xml/OptionPanel.xml rename to xml/Global/OptionPanel.xml diff --git a/xml/TitleSplash.xml b/xml/Global/TitleSplash.xml similarity index 100% rename from xml/TitleSplash.xml rename to xml/Global/TitleSplash.xml diff --git a/xml/UpdateNotification.xml b/xml/Global/UpdateNotification.xml similarity index 100% rename from xml/UpdateNotification.xml rename to xml/Global/UpdateNotification.xml From a459a8b8e71c22d6a89e9f92565e7ba5d43b1960 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 14 Oct 2023 01:38:31 +0200 Subject: [PATCH 37/76] added preview window --- modsettings/CustomUIAssets.json | 15 ++++ src/core/Global.ttslua | 122 ++++++++++++++++++++++++++++++-- xml/Global/DownloadWindow.xml | 55 +++++++++++++- 3 files changed, 187 insertions(+), 5 deletions(-) diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index 402f57df..3a808204 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -218,5 +218,20 @@ "Name": "FinnIcon", "Type": 0, "URL": "http://cloud-3.steamusercontent.com/ugc/2037357792052848566/5DA900C430E97D3DFF2C9B8A3DB1CB2271791FC7/" + }, + { + "Name": "box-cover-mask-small", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2115061298536631564/F29C2ED9DD8431A1D1E21C7FFAFF1FFBC0AF0BF3/" + }, + { + "Name": "box-cover-mask-big", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2115061298536631429/D075D2EECE6EE091AD3BEA5800DEF9C7B02B745B/" + }, + { + "Name": "box-cover-mask-wide", + "Type": 0, + "URL": "http://cloud-3.steamusercontent.com/ugc/2115061298538827369/A20C2ECB8ECDC1B0AD8B2B38F68CA1C1F5E07D37/" } ] diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index fb2682ec..0869664f 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -43,7 +43,7 @@ local hideTitleSplashWaitFunctionId = nil -- online functionality related variables local MOD_VERSION = "3.3.0" local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' -local library, requestObj, modMeta, notificationVisible +local library, requestObj, modMeta, notificationVisible, latestPreviewUpdate local downloadWindowVisible = false local optionPanelVisible = false local acknowledgedUpgradeVersions = {} @@ -657,6 +657,7 @@ function onClick_toggleUi(player, title) elseif title == "Downloadable Content" then if downloadWindowVisible then UI.hide('downloadWindow') + UI.hide("previewWindow") else UI.show('downloadWindow') end @@ -671,6 +672,113 @@ function onClick_toggleUi(player, title) end end +-- hides the content preview window when moving the mouse out of the main window +function onMouseExit_window() + UI.hide("previewWindow") +end + +-- updates the preview window when mousing over any item in the table +function onMouseEnter_item(player, param) + -- only update once per request + if param == latestPreviewUpdate then return end + latestPreviewUpdate = param + + -- hide window in case data is incomplete + UI.hide("previewWindow") + + -- parse parameters + local contentToShow, index + for str in string.gmatch(param, "([^_]+)") do + if not contentToShow then + -- grab the first part to know the content type + contentToShow = str + else + -- get the index + index = tonumber(str) + break + end + end + + if not contentToShow or not index then return end + + -- get metadata from library + local item = library[contentToShow][index] + + UI.setValue("previewTitle", item.name or "Unknown Name") + UI.setValue("previewAuthor", "by " .. (item.author or "Unknown")) + UI.setValue("previewDescription", item.description or "Unknown") + + -- update box art + if not item.boxsize or not item.boxart then return end + + local ui = UI.getXmlTable() + local previewArtPanel = find_tag_with_id(ui, 'previewArtPanel') + + -- update mask according to size + if item.boxsize == "big" then + previewArtPanel.children = { + tag = "Mask", + attributes = { + image = "box-cover-mask-big", + width = "870", + height = "435", + offsetXY = "154 60" + } + } + elseif item.boxsize == "small" then + previewArtPanel.children = { + tag = "Mask", + attributes = { + image = "box-cover-mask-small", + width = "668", + height = "501", + offsetXY = "120 10" + } + } + elseif item.boxsize == "wide" then + previewArtPanel.children = { + tag = "Mask", + attributes = { + image = "box-cover-mask-wide", + width = "780", + height = "650", + offsetXY = "-195 -70" + } + } + end + + -- insert the image itself + previewArtPanel.children.children = { + tag = "Image", + attributes = { image = item.boxart } + } + + UI.setXmlTable(ui) + + -- update the preview window height according to box size + local hWindow, hArt, offsetXY + if item.boxsize == "big" then + hWindow = 510 + hArt = 300 + offsetXY = "-510 135" + elseif item.boxsize == "small" then + hWindow = 510 + hArt = 300 + offsetXY = "-510 135" + elseif item.boxsize == "wide" then + hWindow = 360 + hArt = 150 + offsetXY = "-510 210" + end + + UI.setAttribute("previewWindow", "height", hWindow) + UI.setAttribute("previewWindow", "offsetXY", offsetXY) + UI.setAttribute("previewArtPanel", "preferredHeight", hArt) + + -- show the window + UI.show("previewWindow") +end + -- formats the json response from the webrequest into a key-value lua table -- strips the prefix from the community content items function formatLibrary(json_response) @@ -723,15 +831,21 @@ function update_list(contentToShow) local titleText = find_tag_with_id(ui, "title") titleText.value = "Downloable Content: " .. cleanName[contentToShow] + -- addition of list items according to library file local update_height = find_tag_with_id(ui, 'ui_update_height') local update_children = find_tag_with_id(update_height.children, 'ui_update_point') update_children.children = {} - for _, v in ipairs(library[contentToShow]) do + for i, v in ipairs(library[contentToShow]) do table.insert(update_children.children, - { tag = 'Text', + { + tag = 'Text', value = v.name, - attributes = { onClick = 'onClick_select(' .. urlencode(JSON.encode(v)) .. ')', alignment = 'MiddleLeft' } + attributes = { + onClick = 'onClick_select(' .. urlencode(JSON.encode(v)) .. ')', + onMouseEnter = "onMouseEnter_item(" .. contentToShow .. "_" .. i .. ")", + alignment = 'MiddleLeft' + } }) end diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 45cad1de..12f81d12 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -17,6 +17,7 @@ visibility="Admin" color="black" active="false" + onMouseExit="onMouseExit_window" width="700" height="780" outlineSize="1 1" @@ -80,4 +81,56 @@ textColor="#aaaaaa" fillImageColor="#333333"/> - \ No newline at end of file + + + + + + + + PreviewTitle + by PreviewAuthor + + + + + + + + + + + + + + PreviewDescription + + From 13325c1e89278de1e96fc253d917a96cebb8b67c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 14 Oct 2023 02:10:19 +0200 Subject: [PATCH 38/76] performance improvement --- src/core/Global.ttslua | 49 +++++++++++++++-------------------- xml/Global/DownloadWindow.xml | 4 +++ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0869664f..99fa2aa6 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -704,56 +704,46 @@ function onMouseEnter_item(player, param) -- get metadata from library local item = library[contentToShow][index] - UI.setValue("previewTitle", item.name or "Unknown Name") - UI.setValue("previewAuthor", "by " .. (item.author or "Unknown")) - UI.setValue("previewDescription", item.description or "Unknown") + -- error handling + if not item.name + or not item.author + or not item.description + or not item.boxsize + or not item.boxart then + return + end - -- update box art - if not item.boxsize or not item.boxart then return end + UI.setValue("previewTitle", item.name) + UI.setValue("previewAuthor", "by " .. item.author) + UI.setValue("previewDescription", item.description) - local ui = UI.getXmlTable() - local previewArtPanel = find_tag_with_id(ui, 'previewArtPanel') - -- update mask according to size + local maskData = {} if item.boxsize == "big" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-big", width = "870", height = "435", offsetXY = "154 60" } - } elseif item.boxsize == "small" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-small", width = "668", height = "501", offsetXY = "120 10" } - } elseif item.boxsize == "wide" then - previewArtPanel.children = { - tag = "Mask", - attributes = { + maskData = { image = "box-cover-mask-wide", width = "780", height = "650", offsetXY = "-195 -70" } - } end -- insert the image itself - previewArtPanel.children.children = { - tag = "Image", - attributes = { image = item.boxart } - } - - UI.setXmlTable(ui) + UI.setAttribute("previewArtImage", "image", item.boxart) -- update the preview window height according to box size local hWindow, hArt, offsetXY @@ -771,9 +761,12 @@ function onMouseEnter_item(player, param) offsetXY = "-510 210" end - UI.setAttribute("previewWindow", "height", hWindow) - UI.setAttribute("previewWindow", "offsetXY", offsetXY) + UI.setAttributes("previewArtMask", maskData) UI.setAttribute("previewArtPanel", "preferredHeight", hArt) + UI.setAttributes("previewWindow", { + height = hWindow, + offsetXY = offsetXY + }) -- show the window UI.show("previewWindow") diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 12f81d12..816f9244 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -108,6 +108,10 @@ + + + + - - - Please refresh to see available items. - + flexibleHeight="100" + scrollSensitivity="24"> + + diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml index 78881a7d..7534c85e 100644 --- a/xml/Global/OptionPanel.xml +++ b/xml/Global/OptionPanel.xml @@ -79,7 +79,6 @@ @@ -95,7 +94,8 @@ - + From 6dbf817e20ed7f010208a825c28af3af74aec858 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Sat, 14 Oct 2023 10:20:05 -0400 Subject: [PATCH 47/76] Update ArkhamDb.ttslua with new parallel id range --- src/arkhamdb/ArkhamDb.ttslua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index 0b8c9621..d41da134 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -198,7 +198,7 @@ do local altArt = { front = "normal", back = "normal" } -- translating front ID - if altFrontId > 90000 and altFrontId < 90047 then + if altFrontId > 90000 and altFrontId < 90050 then altArt.front = "parallel" elseif altFrontId > 01500 and altFrontId < 01506 then altArt.front = "revised" @@ -207,7 +207,7 @@ do end -- translating back ID - if altBackId > 90000 and altBackId < 90047 then + if altBackId > 90000 and altBackId < 90050 then altArt.back = "parallel" elseif altBackId > 01500 and altBackId < 01506 then altArt.back = "revised" From 330cc9c25da0e31d3dcdf00227165872f3f755f3 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 14 Oct 2023 18:04:07 +0200 Subject: [PATCH 48/76] bugfix for title name setting --- src/core/Global.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 31dbb110..8245b33f 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -838,7 +838,7 @@ function update_list(contentToShow) fanmadePlayerCards = "Fan-Made Player Cards", fanmadeScenarios = "Fan-Made Scenarios" } - UI.setValue("previewTitle", cleanName[contentToShow]) + UI.setValue("title", "Downloadable Content: " .. cleanName[contentToShow]) -- addition of list items according to library file local childrenTable = {} From c5e87b1e46e4857bbae3685eb4ffe34c95f77d30 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 14 Oct 2023 23:37:50 +0200 Subject: [PATCH 49/76] added highlight effect --- src/core/Global.ttslua | 23 +++++++++++++++++------ xml/Global/DownloadWindow.xml | 10 +++++++++- xml/Global/OptionPanel.xml | 3 ++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 8245b33f..2c686d50 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -627,7 +627,17 @@ end -- forwards the requested content type to the update function ---@param player LuaPlayer Player that triggered this ---@param contentToShow String Name of the content type to show -function onClick_tab(player, contentToShow) +---@param id String Id of the clicked tab +function onClick_tab(player, contentToShow, id) + -- sets highlight to clicked tab + local idTable = {"tab1", "tab2","tab3","tab4","tab5"} + for _, listId in ipairs(idTable) do + if listId == id then + UI.setClass(listId, 'downloadTab activeTab') + else + UI.setClass(listId, 'downloadTab') + end + end update_list(contentToShow) end @@ -705,11 +715,12 @@ function onMouseEnter_item(player, param) local item = library[contentToShow][index] -- error handling - if not item.name - or not item.author - or not item.description - or not item.boxsize - or not item.boxart then + if not item + or not item.name or item.name == "" + or not item.author or item.author == "" + or not item.description or item.description == "" + or not item.boxsize or item.boxsize == "" + or not item.boxart or item.boxart == "" then return end diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 98becdaf..46568c50 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -10,6 +10,9 @@ color="grey"/> diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml index 7534c85e..c108e75f 100644 --- a/xml/Global/OptionPanel.xml +++ b/xml/Global/OptionPanel.xml @@ -80,7 +80,8 @@ + offsetXY="-50 80" + raycastTarget="true"> From c565a70fb5701df77fac63e4c888decf01282fb7 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 15 Oct 2023 09:45:16 +0200 Subject: [PATCH 50/76] added delay --- src/core/Global.ttslua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 2c686d50..43cffd2a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -145,8 +145,10 @@ function onLoad(savedData) getModVersion() math.randomseed(os.time()) - -- initialization of loadable objects library - requestObj = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) + -- initialization of loadable objects library (delay to let Navigation Overlay build) + Wait.time(function() + requestObj = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) + end, 1) end -- Event hook for any object search. When chaos tokens are manipulated while the chaos bag From 8e8cd49001dd9ff07487324967200bf9355bc34b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 15 Oct 2023 09:50:58 +0200 Subject: [PATCH 51/76] edited error handling --- src/core/Global.ttslua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 43cffd2a..39340a30 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -716,19 +716,17 @@ function onMouseEnter_item(player, param) -- get metadata from library local item = library[contentToShow][index] - -- error handling + -- error handling (only author + description can by empty) if not item or not item.name or item.name == "" - or not item.author or item.author == "" - or not item.description or item.description == "" or not item.boxsize or item.boxsize == "" or not item.boxart or item.boxart == "" then return end UI.setValue("previewTitle", item.name) - UI.setValue("previewAuthor", "by " .. item.author) - UI.setValue("previewDescription", item.description) + UI.setValue("previewAuthor", "by " .. (item.author) or "Unknown") + UI.setValue("previewDescription", item.description or "") -- update mask according to size local maskData = {} From 7673a593b3ed8471a32eae521bc2453a081de5e8 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sun, 15 Oct 2023 11:16:15 +0200 Subject: [PATCH 52/76] fixed scrolling in option panel --- xml/Global/OptionPanel.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml index c108e75f..d5289399 100644 --- a/xml/Global/OptionPanel.xml +++ b/xml/Global/OptionPanel.xml @@ -96,7 +96,8 @@ + scrollSensitivity="30" + raycastTarget="true"> From 11f59ebe1c5a31307e15c81d27c1143c85a70e6d Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 16 Oct 2023 00:29:06 +0200 Subject: [PATCH 53/76] moved download button --- src/core/Global.ttslua | 191 ++++++++++++++++++---------------- xml/Global/DownloadWindow.xml | 72 +++++++------ 2 files changed, 145 insertions(+), 118 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 39340a30..5f8dccc0 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -43,10 +43,21 @@ local hideTitleSplashWaitFunctionId = nil -- online functionality related variables local MOD_VERSION = "3.3.0" local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' -local library, requestObj, modMeta, notificationVisible, latestPreviewUpdate -local downloadWindowVisible = false -local optionPanelVisible = false +local library, requestObj, modMeta, contentToShow, currentListItem local acknowledgedUpgradeVersions = {} +local xmlVisibility = { + updateNotification = false, + downloadWindow = false, + previewWindow = false, + optionPanel = false +} +local idTable = { + tab1 = "campaigns", + tab2 = "scenarios", + tab3 = "fanmadeCampaigns", + tab4 = "fanmadeScenarios", + tab5 = "fanmadePlayerCards" +} -- optionPanel data optionPanel = {} @@ -626,45 +637,82 @@ end -- Content Importing and XML functions --------------------------------------------------------- --- forwards the requested content type to the update function ----@param player LuaPlayer Player that triggered this ----@param contentToShow String Name of the content type to show +-- forwards the requested content type to the update function and sets highlight to clicked tab ---@param id String Id of the clicked tab -function onClick_tab(player, contentToShow, id) - -- sets highlight to clicked tab - local idTable = {"tab1", "tab2","tab3","tab4","tab5"} - for _, listId in ipairs(idTable) do +function onClick_tab(_, _, id) + local contentToShow + for listId, listContent in pairs(idTable) do if listId == id then UI.setClass(listId, 'downloadTab activeTab') + contentToShow = listContent else UI.setClass(listId, 'downloadTab') end end update_list(contentToShow) + + -- select the first item + Wait.time(function() onClick_select(_, _, contentToShow .. "_1") end, 0.1) end -- click function for the items in the download window -function onClick_select(player, param) - local parsed = parseKey(param) or {} - local contentToShow = parsed.contentToShow - local index = parsed.index - if not contentToShow or not index then return end - startContentDownload(library[contentToShow][index]) +-- updates backgroundcolor for row panel and fontcolor for list item +function onClick_select(_, _, id) + if currentListItem then + UI.setAttribute("panel" .. currentListItem, "color", "clear") + UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "white") + end + + -- update contentToShow & currentListItem + parseKey(id) + UI.setAttribute("panel" .. currentListItem, "color", "grey") + UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "black") + + updateAndShowPreviewWindow() +end + +-- parses the identification key (contentToShow_currentListItem) +function parseKey(unparsedStr) + contentToShow = nil + currentListItem = nil + for str in string.gmatch(unparsedStr, "([^_]+)") do + if not contentToShow then + -- grab the first part to know the content type + contentToShow = str + else + -- get the index + currentListItem = tonumber(str) + break + end + end +end + +function onClick_download() + startContentDownload(library[contentToShow][currentListItem]) end -- download requested content function startContentDownload(param) local url = SOURCE_REPO .. '/' .. param.url - requestObj = WebRequest.get(url, function (request) complete_obj_download(request, param) end ) + requestObj = WebRequest.get(url, function (request) complete_obj_download(request, param) end) startLuaCoroutine(Global, 'downloadCoroutine') end function downloadCoroutine() + -- show progress bar + UI.setAttribute('download_button', 'active', false) + UI.setAttribute('download_progress', 'active', true) + + -- update progress bar while requestObj do UI.setAttribute('download_progress', 'percentage', requestObj.download_progress * 100) coroutine.yield(0) end UI.setAttribute('download_progress', 'percentage', 100) + + -- hide progress bar + UI.setAttribute('download_button', 'active', true) + UI.setAttribute('download_progress', 'active', false) return 1 end @@ -675,46 +723,33 @@ function onClick_toggleUi(player, title) if title == "Navigation Overlay" then navigationOverlayApi.cycleVisibility(player.color) elseif title == "Downloadable Content" then - if downloadWindowVisible then + if xmlVisibility.downloadWindow then UI.hide('downloadWindow') UI.hide("previewWindow") else + if xmlVisibility.previewWindow then + UI.show("previewWindow") + end UI.show('downloadWindow') end - downloadWindowVisible = not downloadWindowVisible + xmlVisibility.downloadWindow = not xmlVisibility.downloadWindow elseif title == "Options" then - if optionPanelVisible then + if xmlVisibility.optionPanel then UI.hide('optionPanel') else UI.show('optionPanel') end - optionPanelVisible = not optionPanelVisible + xmlVisibility.optionPanel = not xmlVisibility.optionPanel end end --- hides the content preview window when moving the mouse out of the main window -function onMouseExit_window() +-- updates + shows the preview window +function updateAndShowPreviewWindow() + xmlVisibility.previewWindow = false UI.hide("previewWindow") -end - --- updates the preview window when mousing over any item in the table -function onMouseEnter_item(player, param) - -- only update once per request - if param == latestPreviewUpdate then return end - latestPreviewUpdate = param - - -- hide window in case data is incomplete - UI.hide("previewWindow") - - -- parse parameters - local parsed = parseKey(param) or {} - local contentToShow = parsed.contentToShow - local index = parsed.index - - if not contentToShow or not index then return end -- get metadata from library - local item = library[contentToShow][index] + local item = library[contentToShow][currentListItem] -- error handling (only author + description can by empty) if not item @@ -759,17 +794,17 @@ function onMouseEnter_item(player, param) -- update the preview window height according to box size local hWindow, hArt, offsetXY if item.boxsize == "big" then - hWindow = 510 + hWindow = 560 hArt = 300 - offsetXY = "-510 135" + offsetXY = "-476 120" elseif item.boxsize == "small" then - hWindow = 510 + hWindow = 560 hArt = 300 - offsetXY = "-510 135" + offsetXY = "-476 120" elseif item.boxsize == "wide" then - hWindow = 360 + hWindow = 410 hArt = 150 - offsetXY = "-510 210" + offsetXY = "-476 195" end UI.setAttributes("previewArtMask", maskData) @@ -780,28 +815,10 @@ function onMouseEnter_item(player, param) }) -- show the window + xmlVisibility.previewWindow = true UI.show("previewWindow") end --- parses the identification key (contentToShow_index) and returns the result -function parseKey(unparsedStr) - local contentToShow, index - for str in string.gmatch(unparsedStr, "([^_]+)") do - if not contentToShow then - -- grab the first part to know the content type - contentToShow = str - else - -- get the index - index = tonumber(str) - break - end - end - return { - contentToShow = contentToShow, - index = index - } -end - -- formats the json response from the webrequest into a key-value lua table -- strips the prefix from the community content items function formatLibrary(json_response) @@ -852,31 +869,27 @@ function update_list(contentToShow) UI.setValue("title", "Downloadable Content: " .. cleanName[contentToShow]) -- addition of list items according to library file - local childrenTable = {} + local ui = UI.getXmlTable() + local update_point = find_tag_with_id(ui, 'ui_update_point') + update_point.children = {} for i, v in ipairs(library[contentToShow]) do - local key = contentToShow .. "_" .. i - table.insert(childrenTable, + table.insert(update_point.children, { - tag = 'Text', - value = v.name, - attributes = { - onClick = 'onClick_select(' .. key .. ')', - onMouseEnter = "onMouseEnter_item(" .. key .. ")", - alignment = 'MiddleLeft' + tag = "Panel", + attributes = { id = "panel" .. i }, + children = { + tag = 'Text', + value = v.name, + attributes = { + id = contentToShow .. "_" .. i, + onClick = 'onClick_select', + alignment = 'MiddleLeft' + } } }) end - local ui = UI.getXmlTable() - local update_point = find_tag_with_id(ui, 'ui_update_point') - update_point.children = { - tag = 'VerticalLayout', - attributes = { - padding = "10 10 0 0" - }, - children = childrenTable - } - update_point.attributes.height = #childrenTable * 24 + update_point.attributes.height = #update_point.children * 25 UI.setXmlTable(ui) end @@ -920,7 +933,7 @@ function complete_obj_download(request, param) end -- the download button on the placeholder objects calls this to directly initiate a download ----@param param Table contains url and guid of replacement object, which happens to match what onClick_select wants +---@param param Table contains url and guid of replacement object function placeholder_download(param) startContentDownload(param) end @@ -1287,12 +1300,12 @@ end -- triggered by clicking on the Finn Icon function onClick_FinnIcon() - if notificationVisible then + if xmlVisibility.updateNotification then UI.hide("updateNotification") - notificationVisible = false + xmlVisibility.updateNotification = false else UI.show("updateNotification") - notificationVisible = true + xmlVisibility.updateNotification = true end end diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 46568c50..6a220f9f 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -3,6 +3,7 @@ + id="tab1">Official Campaigns + id="tab2">Official Scenarios + id="tab3">Fan-Made Campaigns + id="tab4">Fan-Made Scenarios + id="tab5">Fan-Made Player Cards - + scrollSensitivity="25" + scrollbarColors="grey|grey|#C8C8C8|rgba(0.78,0.78,0.78,0.5)" + horizontalScrollbarVisibility="AutohideAndExpandViewport"> + - + - - - - - @@ -94,11 +84,11 @@ color="black" active="false" width="300" - height="510" + height="560" padding="15 15 5 5" outlineSize="1 1" outline="#303030" - offsetXY="-510 135"> + offsetXY="-476 120"> @@ -142,4 +132,28 @@ fontSize="20" font="font_teutonic-arkham">PreviewDescription + + + + + + + + From 93bf6b343567aa660a7f7f0d99120a25eee321a7 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Sun, 15 Oct 2023 21:40:57 -0400 Subject: [PATCH 54/76] Minor corrections --- .../JimsTrumpet.03c6a7.json | 2 +- .../JimsTrumpet.7dfd5f.json | 2 +- src/arkhamdb/DeckImporterMain.ttslua | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/JimsTrumpet.03c6a7.json b/objects/AllPlayerCards.15bb07/JimsTrumpet.03c6a7.json index fdab72ab..4d0078bf 100644 --- a/objects/AllPlayerCards.15bb07/JimsTrumpet.03c6a7.json +++ b/objects/AllPlayerCards.15bb07/JimsTrumpet.03c6a7.json @@ -22,7 +22,7 @@ "UniqueBack": false } }, - "Description": "The Dead Speak", + "Description": "The Dead Listen", "DragSelectable": true, "GMNotes_path": "AllPlayerCards.15bb07/JimsTrumpet.03c6a7.gmnotes", "GUID": "03c6a7", diff --git a/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json b/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json index 67d9855d..10247fae 100644 --- a/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json +++ b/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json @@ -22,7 +22,7 @@ "UniqueBack": false } }, - "Description": "The Dead Speak (Advanced)", + "Description": "The Dead Listen (Advanced)", "DragSelectable": true, "GMNotes_path": "AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.gmnotes", "GUID": "7dfd5f", diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 8f8151a3..b839bfb3 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -331,7 +331,7 @@ end ---@param playerColor String Color this deck is being loaded for function handleSpiritDeck(investigatorId, cardList, playerColor) if investigatorId == "02004-p" or investigatorId == "02004-pb" then -- Parallel Jim Culver - local spritList = {} + local spiritList = {} for i, card in ipairs(cardList) do if card.metadata.id == "90053" or ( card.metadata.type == "Asset" @@ -339,7 +339,7 @@ function handleSpiritDeck(investigatorId, cardList, playerColor) and string.match(card.metadata.traits, "Ally") and card.metadata.level ~= nil and card.metadata.level < 3) then - table.insert(spritList, i) + table.insert(spiritList, i) end end -- Process allies to move them to the spirit deck. This is done in reverse @@ -347,17 +347,17 @@ function handleSpiritDeck(investigatorId, cardList, playerColor) -- Performance here may be an issue, as table.remove() is an O(n) operation -- which makes the full shift O(n^2). But keep it simple unless it becomes -- a problem - for i = #spritList, 1, -1 do - local moving = cardList[spritList[i]] + for i = #spiritList, 1, -1 do + local moving = cardList[spiritList[i]] moving.zone = "SetAside5" - table.remove(cardList, spritList[i]) + table.remove(cardList, spiritList[i]) table.insert(cardList, moving) end - if #spritList < 10 then - printToAll("Jim's spirit deck must have 9 Ally assets but the deck only has " .. (#spritList - 1) .. + if #spiritList < 10 then + printToAll("Jim's spirit deck must have 9 Ally assets but the deck only has " .. (#spiritList - 1) .. " Ally assets.", playerColor) - elseif #spritList > 11 then - printToAll("Moved all " .. (#spritList - 1) .. + elseif #spiritList > 11 then + printToAll("Moved all " .. (#spiritList - 1) .. " Ally assets to the spirit deck, reduce it to 10 (including Vengeful Shade).", playerColor) else printToAll("Built Jim's spirit deck", playerColor) From e454f9afdf0a7a5a85307bbb44e1fb4928c07ad0 Mon Sep 17 00:00:00 2001 From: Entrox-Licher Date: Mon, 16 Oct 2023 10:12:58 -0400 Subject: [PATCH 55/76] Fixed Jim's Trumpet...again XD --- objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json b/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json index 10247fae..67d9855d 100644 --- a/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json +++ b/objects/AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.json @@ -22,7 +22,7 @@ "UniqueBack": false } }, - "Description": "The Dead Listen (Advanced)", + "Description": "The Dead Speak (Advanced)", "DragSelectable": true, "GMNotes_path": "AllPlayerCards.15bb07/JimsTrumpet.7dfd5f.gmnotes", "GUID": "7dfd5f", From 2edc6e523352594b587d072ccea71c50af31927b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 16 Oct 2023 16:45:18 +0200 Subject: [PATCH 56/76] code cleanup --- src/core/Global.ttslua | 130 ++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 5f8dccc0..e5d93f37 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -158,7 +158,7 @@ function onLoad(savedData) -- initialization of loadable objects library (delay to let Navigation Overlay build) Wait.time(function() - requestObj = WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) + WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) end, 1) end @@ -640,7 +640,6 @@ end -- forwards the requested content type to the update function and sets highlight to clicked tab ---@param id String Id of the clicked tab function onClick_tab(_, _, id) - local contentToShow for listId, listContent in pairs(idTable) do if listId == id then UI.setClass(listId, 'downloadTab activeTab') @@ -649,7 +648,7 @@ function onClick_tab(_, _, id) UI.setClass(listId, 'downloadTab') end end - update_list(contentToShow) + updateDownloadItemList() -- select the first item Wait.time(function() onClick_select(_, _, contentToShow .. "_1") end, 0.1) @@ -663,19 +662,10 @@ function onClick_select(_, _, id) UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "white") end - -- update contentToShow & currentListItem - parseKey(id) - UI.setAttribute("panel" .. currentListItem, "color", "grey") - UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "black") - - updateAndShowPreviewWindow() -end - --- parses the identification key (contentToShow_currentListItem) -function parseKey(unparsedStr) + -- parses the identification key (contentToShow_currentListItem) contentToShow = nil currentListItem = nil - for str in string.gmatch(unparsedStr, "([^_]+)") do + for str in string.gmatch(id, "([^_]+)") do if not contentToShow then -- grab the first part to know the content type contentToShow = str @@ -685,14 +675,21 @@ function parseKey(unparsedStr) break end end + + UI.setAttribute("panel" .. currentListItem, "color", "grey") + UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "black") + + updateAndShowPreviewWindow() end +-- click function for the download button in the preview window function onClick_download() - startContentDownload(library[contentToShow][currentListItem]) + placeholder_download(library[contentToShow][currentListItem]) end --- download requested content -function startContentDownload(param) +-- the download button on the placeholder objects calls this to directly initiate a download +---@param param Table contains url and guid of replacement object +function placeholder_download(param) local url = SOURCE_REPO .. '/' .. param.url requestObj = WebRequest.get(url, function (request) complete_obj_download(request, param) end) startLuaCoroutine(Global, 'downloadCoroutine') @@ -710,9 +707,21 @@ function downloadCoroutine() end UI.setAttribute('download_progress', 'percentage', 100) + -- wait 30 frames + for i = 1, 30 do + coroutine.yield(0) + end + -- hide progress bar UI.setAttribute('download_button', 'active', true) UI.setAttribute('download_progress', 'active', false) + + -- hide download window + if xmlVisibility.downloadWindow then + xmlVisibility.downloadWindow = false + UI.hide('downloadWindow') + UI.hide("previewWindow") + end return 1 end @@ -854,8 +863,7 @@ function formatLibrary(json_response) end -- updates the window content to the requested content ----@param contentToShow String Type of content to show -function update_list(contentToShow) +function updateDownloadItemList() if not library then return end -- set title according to type @@ -896,63 +904,55 @@ end -- called after the webrequest of downloading an item -- deletes the placeholder and spawns the downloaded item function complete_obj_download(request, param) - assert(request.is_done) + requestObj = nil + + -- error handling if request.is_error or request.response_code ~= 200 then - print('error: ' .. request.error) - else - if pcall(function() - local replacedObject - pcall(function() - if param.replace then - replacedObject = getObjectFromGUID(param.replace) - end - end) - if replacedObject then - local pos = replacedObject.getPosition() - local rot = replacedObject.getRotation() - local scale = replacedObject.getScale() - destroyObject(replacedObject) - Wait.frames(function() - spawnObjectJSON({ - json = request.text, - position = pos, - rotation = rot, - scale = scale - }) - end, 1) - else - spawnObjectJSON({ json = request.text }) - end - end) then - print('Object loaded.') - else - print('Error loading object.') + print('Error: ' .. request.error) + return + end + + -- initiate content spawning + local spawnTable = { json = request.text } + if param.replace then + local replacedObject = getObjectFromGUID(param.replace) + if replacedObject then + spawnTable.position = replacedObject.getPosition() + spawnTable.rotation = replacedObject.getRotation() + spawnTable.scale = replacedObject.getScale() + destroyObject(replacedObject) end end - requestObj = nil -end --- the download button on the placeholder objects calls this to directly initiate a download ----@param param Table contains url and guid of replacement object -function placeholder_download(param) - startContentDownload(param) + -- if spawned from menu, ping the position + if param.name then + spawnTable["callback_function"] = function(obj) + Player.getPlayers()[1].pingTable(obj.getPosition()) + end + end + + if pcall(function() spawnObjectJSON(spawnTable) end) then + print('Object loaded.') + else + print('Error loading object.') + end end -- downloading of the library file function completed_list_update(request) - assert(request.is_done) if request.is_error or request.response_code ~= 200 then print('error: ' .. request.error) - else - local json_response = nil - if pcall(function () json_response = JSON.decode(request.text) end) then - formatLibrary(json_response) - update_list("campaigns") - else - print('error parsing downloaded library') - end + return + end + + local json_response = nil + if pcall(function () json_response = JSON.decode(request.text) end) then + formatLibrary(json_response) + contentToShow = "campaigns" + updateDownloadItemList() + else + print('error parsing downloaded library') end - requestObj = nil end -- loops through an XML table and returns the specified object From e045454ff7633284433fb3865b5bd489c06fbc62 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 17 Oct 2023 00:29:07 +0200 Subject: [PATCH 57/76] integrated preview window --- src/core/Global.ttslua | 206 ++++++++++----------------- xml/Global/BottomBar.xml | 4 +- xml/Global/DownloadWindow.xml | 225 ++++++++++++++---------------- xml/Global/OptionPanel.xml | 3 +- xml/Global/UpdateNotification.xml | 5 +- 5 files changed, 182 insertions(+), 261 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index e5d93f37..312155b9 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -43,15 +43,16 @@ local hideTitleSplashWaitFunctionId = nil -- online functionality related variables local MOD_VERSION = "3.3.0" local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' -local library, requestObj, modMeta, contentToShow, currentListItem +local library, requestObj, modMeta local acknowledgedUpgradeVersions = {} +local contentToShow = "campaigns" +local currentListItem = 1 local xmlVisibility = { - updateNotification = false, downloadWindow = false, - previewWindow = false, - optionPanel = false + optionPanel = false, + updateNotification = false } -local idTable = { +local tabIdTable = { tab1 = "campaigns", tab2 = "scenarios", tab3 = "fanmadeCampaigns", @@ -158,7 +159,7 @@ function onLoad(savedData) -- initialization of loadable objects library (delay to let Navigation Overlay build) Wait.time(function() - WebRequest.get(SOURCE_REPO .. '/library.json', completed_list_update) + WebRequest.get(SOURCE_REPO .. '/library.json', libraryDownloadCallback) end, 1) end @@ -638,48 +639,45 @@ end --------------------------------------------------------- -- forwards the requested content type to the update function and sets highlight to clicked tab ----@param id String Id of the clicked tab -function onClick_tab(_, _, id) - for listId, listContent in pairs(idTable) do - if listId == id then +---@param tabId String Id of the clicked tab +function onClick_tab(_, _, tabId) + for listId, listContent in pairs(tabIdTable) do + if listId == tabId then UI.setClass(listId, 'downloadTab activeTab') contentToShow = listContent else UI.setClass(listId, 'downloadTab') end end + currentListItem = 1 updateDownloadItemList() - - -- select the first item - Wait.time(function() onClick_select(_, _, contentToShow .. "_1") end, 0.1) end -- click function for the items in the download window -- updates backgroundcolor for row panel and fontcolor for list item -function onClick_select(_, _, id) - if currentListItem then - UI.setAttribute("panel" .. currentListItem, "color", "clear") - UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "white") - end +function onClick_select(_, _, identificationKey) + UI.setAttribute("panel" .. currentListItem, "color", "clear") + UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "white") -- parses the identification key (contentToShow_currentListItem) - contentToShow = nil - currentListItem = nil - for str in string.gmatch(id, "([^_]+)") do - if not contentToShow then - -- grab the first part to know the content type - contentToShow = str - else - -- get the index - currentListItem = tonumber(str) - break + if identificationKey then + contentToShow = nil + currentListItem = nil + for str in string.gmatch(identificationKey, "([^_]+)") do + if not contentToShow then + -- grab the first part to know the content type + contentToShow = str + else + -- get the index + currentListItem = tonumber(str) + break + end end end UI.setAttribute("panel" .. currentListItem, "color", "grey") UI.setAttribute(contentToShow .. "_" .. currentListItem, "color", "black") - - updateAndShowPreviewWindow() + updatePreviewWindow() end -- click function for the download button in the preview window @@ -691,7 +689,7 @@ end ---@param param Table contains url and guid of replacement object function placeholder_download(param) local url = SOURCE_REPO .. '/' .. param.url - requestObj = WebRequest.get(url, function (request) complete_obj_download(request, param) end) + requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, param) end) startLuaCoroutine(Global, 'downloadCoroutine') end @@ -720,7 +718,6 @@ function downloadCoroutine() if xmlVisibility.downloadWindow then xmlVisibility.downloadWindow = false UI.hide('downloadWindow') - UI.hide("previewWindow") end return 1 end @@ -731,48 +728,32 @@ end function onClick_toggleUi(player, title) if title == "Navigation Overlay" then navigationOverlayApi.cycleVisibility(player.color) - elseif title == "Downloadable Content" then - if xmlVisibility.downloadWindow then - UI.hide('downloadWindow') - UI.hide("previewWindow") - else - if xmlVisibility.previewWindow then - UI.show("previewWindow") - end - UI.show('downloadWindow') - end - xmlVisibility.downloadWindow = not xmlVisibility.downloadWindow - elseif title == "Options" then - if xmlVisibility.optionPanel then - UI.hide('optionPanel') - else - UI.show('optionPanel') - end - xmlVisibility.optionPanel = not xmlVisibility.optionPanel - end -end - --- updates + shows the preview window -function updateAndShowPreviewWindow() - xmlVisibility.previewWindow = false - UI.hide("previewWindow") - - -- get metadata from library - local item = library[contentToShow][currentListItem] - - -- error handling (only author + description can by empty) - if not item - or not item.name or item.name == "" - or not item.boxsize or item.boxsize == "" - or not item.boxart or item.boxart == "" then return end - UI.setValue("previewTitle", item.name) - UI.setValue("previewAuthor", "by " .. (item.author) or "Unknown") - UI.setValue("previewDescription", item.description or "") + if xmlVisibility[title] then + UI.hide(title) + else + UI.show(title) + end + xmlVisibility[title] = not xmlVisibility[title] +end - -- update mask according to size +-- updates the preview window +function updatePreviewWindow() + local item = library[contentToShow][currentListItem] + + -- set default image if not defined + if item.boxsize == nil or item.boxsize == "" or item.boxart == nil or item.boxart == "" then + item.boxsize = "big" + item.boxart = "http://cloud-3.steamusercontent.com/ugc/762723517667628371/18438B0A0045038A7099648AA3346DFCAA267C66/" + end + + UI.setValue("previewTitle", item.name) + UI.setValue("previewAuthor", "by " .. (item.author) or "- Author not found -") + UI.setValue("previewDescription", item.description or "- Description not found -") + + -- update mask according to size (hardcoded values to align image in mask) local maskData = {} if item.boxsize == "big" then maskData = { @@ -784,48 +765,22 @@ function updateAndShowPreviewWindow() elseif item.boxsize == "small" then maskData = { image = "box-cover-mask-small", - width = "668", - height = "501", - offsetXY = "120 10" + width = "792", + height = "594", + offsetXY = "135 13" } elseif item.boxsize == "wide" then maskData = { image = "box-cover-mask-wide", - width = "780", - height = "650", - offsetXY = "-195 -70" + width = "756", + height = "630", + offsetXY = "-190 -70" } end -- insert the image itself UI.setAttribute("previewArtImage", "image", item.boxart) - - -- update the preview window height according to box size - local hWindow, hArt, offsetXY - if item.boxsize == "big" then - hWindow = 560 - hArt = 300 - offsetXY = "-476 120" - elseif item.boxsize == "small" then - hWindow = 560 - hArt = 300 - offsetXY = "-476 120" - elseif item.boxsize == "wide" then - hWindow = 410 - hArt = 150 - offsetXY = "-476 195" - end - UI.setAttributes("previewArtMask", maskData) - UI.setAttribute("previewArtPanel", "preferredHeight", hArt) - UI.setAttributes("previewWindow", { - height = hWindow, - offsetXY = offsetXY - }) - - -- show the window - xmlVisibility.previewWindow = true - UI.show("previewWindow") end -- formats the json response from the webrequest into a key-value lua table @@ -866,22 +821,13 @@ end function updateDownloadItemList() if not library then return end - -- set title according to type - local cleanName = { - campaigns = "Campaigns", - scenarios = "Scenarios", - fanmadeCampaigns = "Fan-Made Campaigns", - fanmadePlayerCards = "Fan-Made Player Cards", - fanmadeScenarios = "Fan-Made Scenarios" - } - UI.setValue("title", "Downloadable Content: " .. cleanName[contentToShow]) - -- addition of list items according to library file - local ui = UI.getXmlTable() - local update_point = find_tag_with_id(ui, 'ui_update_point') - update_point.children = {} + local globalXml = UI.getXmlTable() + local contentList = getXmlTableElementById(globalXml, 'contentList') + + contentList.children = {} for i, v in ipairs(library[contentToShow]) do - table.insert(update_point.children, + table.insert(contentList.children, { tag = "Panel", attributes = { id = "panel" .. i }, @@ -897,13 +843,16 @@ function updateDownloadItemList() }) end - update_point.attributes.height = #update_point.children * 25 - UI.setXmlTable(ui) + contentList.attributes.height = #contentList.children * 27 + UI.setXmlTable(globalXml) + + -- select the first item + Wait.time(onClick_select, 0.2) end -- called after the webrequest of downloading an item -- deletes the placeholder and spawns the downloaded item -function complete_obj_download(request, param) +function contentDownloadCallback(request, param) requestObj = nil -- error handling @@ -939,7 +888,7 @@ function complete_obj_download(request, param) end -- downloading of the library file -function completed_list_update(request) +function libraryDownloadCallback(request) if request.is_error or request.response_code ~= 200 then print('error: ' .. request.error) return @@ -948,7 +897,6 @@ function completed_list_update(request) local json_response = nil if pcall(function () json_response = JSON.decode(request.text) end) then formatLibrary(json_response) - contentToShow = "campaigns" updateDownloadItemList() else print('error parsing downloaded library') @@ -958,11 +906,11 @@ end -- loops through an XML table and returns the specified object ---@param ui Table XmlTable (get this via getXmlTable) ---@param id String Id of the object to return -function find_tag_with_id(ui, id) +function getXmlTableElementById(ui, id) for _, obj in ipairs(ui) do if obj.attributes and obj.attributes.id and obj.attributes.id == id then return obj end if obj.children then - local result = find_tag_with_id(obj.children, id) + local result = getXmlTableElementById(obj.children, id) if result then return result end end end @@ -1298,17 +1246,6 @@ function updateNotificationLoading() UI.setAttribute("updateNotification", "height", 20*#highlights + 125) end --- triggered by clicking on the Finn Icon -function onClick_FinnIcon() - if xmlVisibility.updateNotification then - UI.hide("updateNotification") - xmlVisibility.updateNotification = false - else - UI.show("updateNotification") - xmlVisibility.updateNotification = true - end -end - -- close / don't show again buttons on the update notification function onClick_notification(_, parameter) if parameter == "dontShowAgain" then @@ -1317,4 +1254,5 @@ function onClick_notification(_, parameter) end UI.hide("FinnIcon") UI.hide("updateNotification") + xmlVisibility["updateNotification"] = false end diff --git a/xml/Global/BottomBar.xml b/xml/Global/BottomBar.xml index f7204b91..55f595a5 100644 --- a/xml/Global/BottomBar.xml +++ b/xml/Global/BottomBar.xml @@ -18,11 +18,11 @@ - - - - - + + + + + + + + + + - - - - + + + + + + - - - - + + - - - PreviewTitle - by PreviewAuthor - + + + PreviewTitle + by PreviewAuthor + - - - - - + + + + + + + - + + + PreviewDescription + - - - - - - - - PreviewDescription - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/xml/Global/OptionPanel.xml b/xml/Global/OptionPanel.xml index d5289399..b82bb725 100644 --- a/xml/Global/OptionPanel.xml +++ b/xml/Global/OptionPanel.xml @@ -79,6 +79,7 @@ @@ -358,7 +359,7 @@ + onClick="onClick_toggleUi(optionPanel)">Close diff --git a/xml/Global/UpdateNotification.xml b/xml/Global/UpdateNotification.xml index 21dedd89..6649ea90 100644 --- a/xml/Global/UpdateNotification.xml +++ b/xml/Global/UpdateNotification.xml @@ -10,10 +10,11 @@ offsetXY="420 -5" height="90" width="90" - onClick="onClick_FinnIcon" + onClick="onClick_toggleUi(updateNotification)" image="FinnIcon" tooltip="Update notification" - tooltipBackgroundColor="rgba(0,0,0,0.8)"/> + tooltipPosition="Right" + tooltipBackgroundColor="rgba(0,0,0,1)"/> Date: Tue, 17 Oct 2023 10:50:15 +0200 Subject: [PATCH 58/76] more bugfixing --- src/accessories/TokenArranger.ttslua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/accessories/TokenArranger.ttslua b/src/accessories/TokenArranger.ttslua index fb836480..2be2c7cd 100644 --- a/src/accessories/TokenArranger.ttslua +++ b/src/accessories/TokenArranger.ttslua @@ -312,6 +312,10 @@ function layout(_, _, isRightClick) local value = tonumber(objData.Nickname) local precedence = tokenPrecedence[objData.Nickname] + -- remove GUID to avoid issues for high latency clients + objData["GUID"] = nil + + -- store data with value / precendence data[i] = { token = objData, value = value or precedence[1] From 1c6984c9c6431e582c5570be344df078aafce8d9 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 17 Oct 2023 22:58:59 +0200 Subject: [PATCH 59/76] spawn correct amount of bonded cards --- src/arkhamdb/ArkhamDb.ttslua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arkhamdb/ArkhamDb.ttslua b/src/arkhamdb/ArkhamDb.ttslua index d41da134..eb3dcf41 100644 --- a/src/arkhamdb/ArkhamDb.ttslua +++ b/src/arkhamdb/ArkhamDb.ttslua @@ -295,7 +295,12 @@ do local card = allCardsBagApi.getCardById(cardId) if (card ~= nil and card.metadata.bonded ~= nil) then for _, bond in ipairs(card.metadata.bonded) do - bondedCards[bond.id] = bond.count + -- add a bonded card for each copy of the parent card (except for Pendant of the Queen) + if bond.id == "06022" then + bondedCards[bond.id] = bond.count + else + bondedCards[bond.id] = bond.count * cardCount + end -- We need to know which cards are bonded to determine their position, remember them bondedList[bond.id] = true -- Also adding taboo versions of bonded cards to the list From 838aa5234b8ad6474d61133200c27cd1d14f4b68 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 17 Oct 2023 23:11:17 +0200 Subject: [PATCH 60/76] fixed area size to detect top card --- src/playermat/Playmat.ttslua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index af2e2a4c..0159b886 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -68,7 +68,7 @@ local DECK_DISCARD_AREA = { }, size = { x = 0.4, - y = 0.1, + y = 1, z = 1.1 } } @@ -425,10 +425,13 @@ function drawCardsWithReshuffle(numCards) -- Norman Withers handling if string.match(activeInvestigatorId, "%d%d%d%d%d") == "08004" then local harbinger = false - if topCard ~= nil and topCard.getName() == "The Harbinger" then harbinger = true + if topCard ~= nil and topCard.getName() == "The Harbinger" then + harbinger = true elseif drawDeck ~= nil and not drawDeck.is_face_down then local cards = drawDeck.getObjects() - if cards[#cards].name == "The Harbinger" then harbinger = true end + if cards[#cards].name == "The Harbinger" then + harbinger = true + end end if harbinger then From 4159dfc43d31337c6e2baef2e9706f9451965390 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 18 Oct 2023 20:55:38 +0200 Subject: [PATCH 61/76] resolving review comments --- .../CampaignImporterExporter.ttslua | 5 ++-- src/accessories/CleanUpHelper.ttslua | 29 +++++++++---------- src/accessories/TokenArrangerApi.ttslua | 4 +-- src/arkhamdb/DeckImporterApi.ttslua | 5 ++-- src/chaosbag/BlessCurseManagerApi.ttslua | 4 +-- src/core/DoomCounter.ttslua | 9 +++--- src/core/DoomInPlayCounter.ttslua | 7 ++--- src/core/GUIDReferenceApi.ttslua | 28 ++++++++++++++++++ src/core/GUIDReferenceHandler.ttslua | 6 ++-- src/core/GameKeyHandler.ttslua | 5 ++-- src/core/Global.ttslua | 4 +-- src/core/MythosArea.ttslua | 7 ++--- src/core/MythosAreaApi.ttslua | 4 +-- src/core/NavigationOverlayApi.ttslua | 4 +-- src/core/PlayArea.ttslua | 4 +-- src/core/PlayAreaApi.ttslua | 7 ++--- src/core/SoundCubeApi.ttslua | 4 +-- src/core/VictoryDisplay.ttslua | 17 ++--------- src/core/VictoryDisplayApi.ttslua | 4 +-- src/core/token/TokenManager.ttslua | 9 +++--- src/core/token/TokenSpawnTracker.ttslua | 14 +-------- src/core/token/TokenSpawnTrackerApi.ttslua | 4 +-- src/core/tour/TourManager.ttslua | 11 +++---- src/playercards/AllCardsBagApi.ttslua | 4 +-- src/playermat/ClueCounter.ttslua | 20 +++++-------- src/playermat/Playmat.ttslua | 5 ++-- src/playermat/PlaymatApi.ttslua | 6 ++-- 27 files changed, 112 insertions(+), 118 deletions(-) create mode 100644 src/core/GUIDReferenceApi.ttslua diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 8b5e6075..80facb5f 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -1,12 +1,11 @@ local blessCurseApi = require("chaosbag/BlessCurseManagerApi") local chaosBagApi = require("chaosbag/ChaosBagApi") local deckImporterApi = require("arkhamdb/DeckImporterApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local optionPanelApi = require("core/OptionPanelApi") local playAreaApi = require("core/PlayAreaApi") local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectFromGUID("123456") - local campaignTokenData = { Name = "Custom_Model", Transform = { @@ -165,7 +164,7 @@ function createCampaignFromToken(importData) Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5) -- destroy Tour Starter token - local tourStarter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TourStarter" }) + local tourStarter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TourStarter") tourStarter.destruct() -- restore PlayArea image diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index c1d66f5b..8fef10e5 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -3,14 +3,13 @@ - puts everything on playmats and hands into respective trashcans - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")]] -local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") -local chaosBagApi = require("chaosbag/ChaosBagApi") -local playAreaApi = require("core/PlayAreaApi") -local playmatApi = require("playermat/PlaymatApi") -local soundCubeApi = require("core/SoundCubeApi") -local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") - -local guidHandler = getObjectFromGUID("123456") +local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local chaosBagApi = require("chaosbag/ChaosBagApi") +local guidReferenceApi = require("core/GUIDReferenceApi") +local playAreaApi = require("core/PlayAreaApi") +local playmatApi = require("playermat/PlaymatApi") +local soundCubeApi = require("core/SoundCubeApi") +local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -- objects with this tag will be ignored local IGNORE_TAG = "CleanUpHelper_ignore" @@ -146,7 +145,7 @@ end -- reset doom on agenda function resetDoomCounter() - local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) + local doomCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomCounter") if doomCounter ~= nil then doomCounter.call("updateVal") else @@ -231,7 +230,7 @@ end function discardHands() if not options["tidyPlayermats"] then return end for i = 1, 4 do - local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) + local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash") if trash == nil then return end local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects() for j = #hand, 1, -1 do @@ -242,8 +241,8 @@ end -- clean up for play area function tidyPlayareaCoroutine() - local trash = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) - local playAreaZone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) + local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") + local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone") if playAreaZone == nil then printToAll("Scripting zone for main play area could not be found!", "Red") @@ -273,7 +272,7 @@ function tidyPlayerMatCoroutine() for k = 1, 30 do coroutine.yield(0) end -- get respective trash - local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) + local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash") if trash == nil then printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red") return 1 @@ -303,7 +302,7 @@ function tidyPlayerMatCoroutine() -- reset "activeInvestigatorId" if i < 5 then - local playermat = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Playermat" }) + local playermat = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Playermat") if playermat then playermat.setVar("activeInvestigatorId", "00000") end @@ -311,7 +310,7 @@ function tidyPlayerMatCoroutine() end end - local datahelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) + local datahelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") if datahelper then datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {}) end diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 846c0648..75d44839 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -1,12 +1,12 @@ do local TokenArrangerApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") -- 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 guidHandler = getObjectFromGUID("123456") - local tokenArranger = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenArranger" }) + local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger") if tokenArranger ~= nil then tokenArranger.call(functionName, argument) end diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 221a5f5d..8628b6c4 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -1,10 +1,9 @@ do local DeckImporterApi = {} - + local guidReferenceApi = require("core/GUIDReferenceApi") local function getDeckImporter() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "DeckImporter") end -- Returns a table with the full state of the UI, including options and deck IDs. diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index d0cd5b9c..7612eae5 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,9 +1,9 @@ do local BlessCurseManagerApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getManager() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "BlessCurseManager" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "BlessCurseManager") end -- removes all taken tokens and resets the counts diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index f39ad72d..ae649189 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -1,10 +1,11 @@ +local guidReferenceApi = require("core/GUIDReferenceApi") + local optionsVisible = false local options = { Agenda = true, Playarea = true, Playermats = true } -local guidHandler = getObjectFromGUID("123456") val = 0 @@ -65,9 +66,9 @@ function startReset() if options.Agenda then updateVal(0) end - local DoomInPlayCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomInPlayCounter" }) - if DoomInPlayCounter then - DoomInPlayCounter.call("removeDoom", options) + local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter") + if doomInPlayCounter then + doomInPlayCounter.call("removeDoom", options) end end diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index cb851055..b844939a 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,7 +1,6 @@ +local guidReferenceApi = require("core/GUIDReferenceApi") local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectFromGUID("123456") - local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" local IGNORE_TAG = "DoomCounter_ignore" @@ -31,8 +30,8 @@ function onLoad() color = { 0, 0, 0, 0 } }) - TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) - ZONE = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) + TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") + ZONE = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone") loopID = Wait.time(countDoom, 2, -1) end diff --git a/src/core/GUIDReferenceApi.ttslua b/src/core/GUIDReferenceApi.ttslua new file mode 100644 index 00000000..3728eb09 --- /dev/null +++ b/src/core/GUIDReferenceApi.ttslua @@ -0,0 +1,28 @@ +do + local GUIDReferenceApi = {} + + local function getGuidHandler() + return getObjectFromGUID("123456") + end + + -- returns all matching objects as a table with references + ---@param owner String Parent object for this search + ---@param type String Type of object to search for + GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type) + return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type }) + end + + -- returns all matching objects as a table with references + ---@param type String Type of object to search for + GUIDReferenceApi.getObjectsByType = function(type) + return getGuidHandler().call("getObjectsByType", type) + end + + -- returns all matching objects as a table with references + ---@param owner String Parent object for this search + GUIDReferenceApi.getObjectsByOwner = function(owner) + return getGuidHandler().call("getObjectsByOwner", owner) + end + + return GUIDReferenceApi +end diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua index c125f5d1..b770c057 100644 --- a/src/core/GUIDReferenceHandler.ttslua +++ b/src/core/GUIDReferenceHandler.ttslua @@ -71,9 +71,9 @@ local GuidReferences = { } } -function getObjectByOwnerAndType(param) - local owner = param.owner - local type = param.type +function getObjectByOwnerAndType(params) + local owner = params.owner or "Mythos" + local type = params.type return getObjectFromGUID(GuidReferences[owner][type]) end diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index b1427e37..5fb80afd 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -1,10 +1,9 @@ local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") -local guidHandler = getObjectFromGUID("123456") - function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Bless/Curse Status", showBlessCurseStatus) @@ -43,7 +42,7 @@ end -- adds 1 doom to the agenda function addDoomToAgenda() - local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) + local doomCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomCounter") doomCounter.call("addVal", 1) end diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index bb2ba922..5add6fe7 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -1,4 +1,5 @@ local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local mythosAreaApi = require("core/MythosAreaApi") local navigationOverlayApi = require("core/NavigationOverlayApi") local playAreaApi = require("core/PlayAreaApi") @@ -135,8 +136,7 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - guidHandler = getObjectFromGUID("123456") - DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) + DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") resetChaosTokenStatTracker() getModVersion() math.randomseed(os.time()) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 12100390..fada0072 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -1,10 +1,9 @@ +local guidReferenceApi = require("core/GUIDReferenceApi") local playAreaApi = require("core/PlayAreaApi") local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local guidHandler = getObjectFromGUID("123456") - local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, lowerRight = { x = 0.86, z = 0.38 }, @@ -35,8 +34,8 @@ function onLoad(saveState) useFrontData = loadedState.useFrontData or true tokenData = loadedState.tokenData or {} end - TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) - DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) + TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") + DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") collisionEnabled = true end diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index e9908ab7..08caeb1d 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -1,9 +1,9 @@ do local MythosAreaApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getMythosArea() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MythosArea" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "MythosArea") end -- returns the chaos token metadata (if provided through scenario reference card) diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index e1249730..a39b0879 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -1,9 +1,9 @@ do local NavigationOverlayApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getNOHandler() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "NavigationOverlayHandler" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler") end -- Copies the visibility for the Navigation overlay diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 9a284a59..453de993 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -44,6 +44,7 @@ local LOC_LINK_EXCLUDE_SCENARIOS = { ["The Heart of Madness"] = true } +local guidReferenceApi = require("core/GUIDReferenceApi") local tokenManager = require("core/token/TokenManager") local clueData = {} @@ -513,8 +514,7 @@ function shiftContentsRight(playerColor) end function shiftContents(playerColor, direction) - local guidHandler = getObjectFromGUID("123456") - local zone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) + local zone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone") if not zone then broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") return diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index e903e2c8..f1281b40 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,14 +1,13 @@ do local PlayAreaApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getPlayArea() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayArea" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayArea") end local function getInvestigatorCounter() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "InvestigatorCounter" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "InvestigatorCounter") end -- Returns the current value of the investigator counter from the playmat diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 36db9085..8aec117b 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -1,5 +1,6 @@ do local SoundCubeApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") -- this table links the name of a trigger effect to its index local soundIndices = { @@ -9,8 +10,7 @@ do } local function playTriggerEffect(index) - local guidHandler = getObjectFromGUID("123456") - local SoundCube = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "SoundCube" }) + local SoundCube = guidReferenceApi.getObjectByOwnerAndType("Mythos", "SoundCube") SoundCube.AssetBundle.playTriggerEffect(index) end diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index 3226cbbc..c4c95a0e 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -1,4 +1,5 @@ local chaosBagApi = require("chaosbag/ChaosBagApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local playAreaApi = require("core/PlayAreaApi") local tokenChecker = require("core/token/TokenChecker") @@ -10,8 +11,6 @@ local countedVP = {} local highlightMissing = false local highlightCounted = false -local guidHandler = getObjectFromGUID("123456") - -- button creation when loading the game function onLoad() -- index 0: VP - "Display" @@ -250,7 +249,7 @@ end -- places the provided card in the first empty spot function placeCard(card) - local TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) + local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash") -- check snap point states local snaps = self.getSnapPoints() @@ -281,7 +280,7 @@ function placeCard(card) local chaosBag = chaosBagApi.findChaosBag() chaosBag.putObject(obj) elseif obj.memo ~= nil and obj.getLock() == false then - TRASH.putObject(obj) + trash.putObject(obj) end end @@ -325,13 +324,3 @@ function checkSnapPointState(pos) origin = pos }) end - --- search a table for a value, return true if found (else returns false) -function tableContains(table, value) - for _, v in ipairs(table) do - if v == value then - return true - end - end - return false -end diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index 32ee9878..ae057130 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -1,9 +1,9 @@ do local VictoryDisplayApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getVictoryDisplay() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay") end -- triggers an update of the Victory count diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 297c7061..adcfae82 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -1,4 +1,5 @@ do + local guidReferenceApi = require("core/GUIDReferenceApi") local optionPanelApi = require("core/OptionPanelApi") local playAreaApi = require("core/PlayAreaApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") @@ -335,9 +336,8 @@ do if tokenTemplates ~= nil then return end - tokenTemplates = { } - local guidHandler = getObjectFromGUID("123456") - local tokenSource = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSource" }) + tokenTemplates = {} + local tokenSource = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenSource") for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do local tokenName = tokenTemplate.Memo tokenTemplates[tokenName] = tokenTemplate @@ -349,8 +349,7 @@ do if playerCardData ~= nil then return end - local guidHandler = getObjectFromGUID("123456") - local dataHelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) + local dataHelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA') end diff --git a/src/core/token/TokenSpawnTracker.ttslua b/src/core/token/TokenSpawnTracker.ttslua index 6c9fc9eb..02aaf415 100644 --- a/src/core/token/TokenSpawnTracker.ttslua +++ b/src/core/token/TokenSpawnTracker.ttslua @@ -53,19 +53,7 @@ end -- Listener to reset card token spawns when they enter a hand. function onObjectEnterZone(zone, enterObject) - if checkMemo(zone) then + if zone.type == "Hand" and enterObject.type == "Card" then resetTokensSpawned(enterObject.getGUID()) end end - --- checks if the object is owned by a playermat -function checkMemo(obj) - local memo = obj.getMemo() - if memo then - local decoded = JSON.decode(memo) or {} - if decoded.matColor ~= "Mythos" then - return true - end - end - return false -end diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index e82f3057..1ba4c261 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,9 +1,9 @@ do local TokenSpawnTracker = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getSpawnTracker() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSpawnTracker" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenSpawnTracker") end TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index 2b0ec255..c27939ee 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -1,8 +1,9 @@ do require("core/tour/TourScript") require("core/tour/TourCard") - local TourManager = { } - local internal = { } + local TourManager = {} + local internal = {} + local guidReferenceApi = require("core/GUIDReferenceApi") -- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended local CARD_ID = "tourCard" @@ -123,9 +124,9 @@ do delay = delay + 0.5 end local lookPos - if TOUR_SCRIPT[cardIndex].objReferenceData ~= nil then - local guidHandler = getObjectFromGUID("123456") - local lookAtObj = guidHandler.call("getObjectByOwnerAndType", TOUR_SCRIPT[cardIndex].objReferenceData) + local objReferenceData = TOUR_SCRIPT[cardIndex].objReferenceData + if objReferenceData ~= nil then + local lookAtObj = guidReferenceApi.getObjectByOwnerAndType(objReferenceData.owner, objReferenceData.type) lookPos = lookAtObj.getPosition() lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0 -- Since camera isn't directly above the hook, changing the Y affects the visual position of diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 6178c6f1..83cf6463 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -1,9 +1,9 @@ do local AllCardsBagApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") local function getAllCardsBag() - local guidHandler = getObjectFromGUID("123456") - return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "AllCardsBag" }) + return guidReferenceApi.getObjectByOwnerAndType("Mythos", "AllCardsBag") end -- Returns a specific card from the bag, based on ArkhamDB ID diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 251fb070..cce78085 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -26,16 +26,15 @@ end -- Activated once per second, counts items in bowls function countItems() local totalValue = 0 - local countableItems = findValidItemsInSphere() - for _, entry in ipairs(countableItems) do - local descValue = tonumber(entry.hit_object.getDescription()) - local stackMult = math.abs(entry.hit_object.getQuantity()) + for _, item in ipairs(findValidItemsInSphere()) do + local descValue = tonumber(item.getDescription()) + local stackMult = math.abs(item.getQuantity()) -- Use value in description if available if descValue ~= nil then totalValue = totalValue + descValue * stackMult else -- Otherwise use the value in validCountItemList - totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult + totalValue = totalValue + validCountItemList[item.getName()] * stackMult end end exposedValue = totalValue @@ -51,18 +50,15 @@ function findValidItemsInSphere() size = { 2, 2, 2 } }) - retval = {} + local validItemList = {} for _, entry in ipairs(items) do - --Ignore the bowl if entry.hit_object ~= self then - --Ignore if not in validCountItemList - local tableEntry = validCountItemList[entry.hit_object.getName()] - if tableEntry ~= nil then - table.insert(retval, entry) + if validCountItemList[entry.hit_object.getName()] ~= nil then + table.insert(validItemList, entry.hit_object) end end end - return retval + return validItemList end function removeAllClues(trash) diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 0159b886..3ddefdfb 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -1,11 +1,10 @@ local chaosBagApi = require("chaosbag/ChaosBagApi") +local guidReferenceApi = require("core/GUIDReferenceApi") local mythosAreaApi = require("core/MythosAreaApi") local navigationOverlayApi = require("core/NavigationOverlayApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") -local guidHandler = getObjectFromGUID("123456") - -- set true to enable debug logging and show Physics.cast() local DEBUG = false @@ -105,7 +104,7 @@ function onLoad(saveState) self.interactable = DEBUG -- get object references to owned objects - ownedObjects = guidHandler.call("getObjectsByOwner", matColor) + ownedObjects = guidReferenceApi.getObjectsByOwner(matColor) -- button creation for i = 1, 6 do diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 6fb11f28..a051cfe6 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -1,15 +1,15 @@ do local PlaymatApi = {} + local guidReferenceApi = require("core/GUIDReferenceApi") -- Convenience function to look up a mat's object by color, or get all mats. ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@return array Table Single-element if only single playmat is requested local function getMatForColor(matColor) - local guidHandler = getObjectFromGUID("123456") if matColor == "All" then - return guidHandler.call("getObjectsByType", "Playermat") + return guidReferenceApi.getObjectsByType("Playermat") else - return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } + return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") } end end From 751be191e8449b5e5c16be063243a6980ce0fcb5 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 18 Oct 2023 21:37:42 +0200 Subject: [PATCH 62/76] resolving review comments --- src/core/Global.ttslua | 39 +++++++++++++++++++---------------- xml/Global/DownloadWindow.xml | 18 ++++++++-------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 312155b9..8b68fbc2 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -238,12 +238,12 @@ function canTouchChaosTokens() end -- called by playermats (by the "Draw chaos token" button) -function drawChaosToken(param) +function drawChaosToken(params) if not canTouchChaosTokens() then return end - local mat = param[1] - local tokenOffset = param[2] - local isRightClick = param[3] + local mat = params[1] + local tokenOffset = params[2] + local isRightClick = params[3] chaosbag = findChaosBag() -- return token(s) on other playmat first @@ -289,9 +289,9 @@ end -- DEPRECATED. Use TokenManager instead. -- Spawns a single token. ----@param param Table. Array with arguments to the method. 1 = position, 2 = type, 3 = rotation -function spawnToken(param) - return tokenManager.spawnToken(param[1], param[2], param[3]) +---@param params Table. Array with arguments to the method. 1 = position, 2 = type, 3 = rotation +function spawnToken(params) + return tokenManager.spawnToken(params[1], params[2], params[3]) end --------------------------------------------------------- @@ -687,15 +687,14 @@ end -- the download button on the placeholder objects calls this to directly initiate a download ---@param param Table contains url and guid of replacement object -function placeholder_download(param) - local url = SOURCE_REPO .. '/' .. param.url - requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, param) end) +function placeholder_download(params) + local url = SOURCE_REPO .. '/' .. params.url + requestObj = WebRequest.get(url, function (request) contentDownloadCallback(request, params) end) startLuaCoroutine(Global, 'downloadCoroutine') end function downloadCoroutine() -- show progress bar - UI.setAttribute('download_button', 'active', false) UI.setAttribute('download_progress', 'active', true) -- update progress bar @@ -711,7 +710,6 @@ function downloadCoroutine() end -- hide progress bar - UI.setAttribute('download_button', 'active', true) UI.setAttribute('download_progress', 'active', false) -- hide download window @@ -732,7 +730,8 @@ function onClick_toggleUi(player, title) end if xmlVisibility[title] then - UI.hide(title) + -- small delay to allow button click sounds to play + Wait.time(function() UI.hide(title) end, 0.1) else UI.show(title) end @@ -742,6 +741,7 @@ end -- updates the preview window function updatePreviewWindow() local item = library[contentToShow][currentListItem] + local tempImage = "http://cloud-3.steamusercontent.com/ugc/2115061845788345842/2CD6ABC551555CCF58F9D0DDB7620197BA398B06/" -- set default image if not defined if item.boxsize == nil or item.boxsize == "" or item.boxart == nil or item.boxart == "" then @@ -750,7 +750,7 @@ function updatePreviewWindow() end UI.setValue("previewTitle", item.name) - UI.setValue("previewAuthor", "by " .. (item.author) or "- Author not found -") + UI.setValue("previewAuthor", "by " .. (item.author or "- Author not found -")) UI.setValue("previewDescription", item.description or "- Description not found -") -- update mask according to size (hardcoded values to align image in mask) @@ -778,6 +778,9 @@ function updatePreviewWindow() } end + -- loading empty image as placeholder until real image is loaded + UI.setAttribute("previewArtImage", "image", tempImage) + -- insert the image itself UI.setAttribute("previewArtImage", "image", item.boxart) UI.setAttributes("previewArtMask", maskData) @@ -852,7 +855,7 @@ end -- called after the webrequest of downloading an item -- deletes the placeholder and spawns the downloaded item -function contentDownloadCallback(request, param) +function contentDownloadCallback(request, params) requestObj = nil -- error handling @@ -863,8 +866,8 @@ function contentDownloadCallback(request, param) -- initiate content spawning local spawnTable = { json = request.text } - if param.replace then - local replacedObject = getObjectFromGUID(param.replace) + if params.replace then + local replacedObject = getObjectFromGUID(params.replace) if replacedObject then spawnTable.position = replacedObject.getPosition() spawnTable.rotation = replacedObject.getRotation() @@ -874,7 +877,7 @@ function contentDownloadCallback(request, param) end -- if spawned from menu, ping the position - if param.name then + if params.name then spawnTable["callback_function"] = function(obj) Player.getPlayers()[1].pingTable(obj.getPosition()) end diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 6e1b2f7f..8b11460b 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -114,15 +114,6 @@ - - + + From d4cb0eb2f0daaaf26e13a810c5985f9080411664 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 18 Oct 2023 22:51:23 +0200 Subject: [PATCH 63/76] added laid to rest --- .../ChallengeScenarios.9f6801.json | 1 + .../LaidtoRest.e2dd57.json | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json index db2728ef..32939093 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json @@ -17,6 +17,7 @@ "BadBlood.451eaa", "RedTideRising.5302f2", "AllorNothing.72ab92", + "LaidtoRest.e2dd57", "ReadorDie.9e73fa", "BytheBook.cc7eb3" ], diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json new file mode 100644 index 00000000..a4921ec9 --- /dev/null +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json @@ -0,0 +1,86 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "AttachedDecals": [ + { + "CustomDecal": { + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/959719855119695911/931B9829687A20F4DEADB36DA57B7E6D76792231/", + "Name": "dunwich_back", + "Size": 7.4 + }, + "Transform": { + "posX": 0, + "posY": 0, + "posZ": 0, + "rotX": 270, + "rotY": 0, + "rotZ": 0, + "scaleX": 2, + "scaleY": 2, + "scaleZ": 2 + } + } + ], + "Autoraise": true, + "ColorDiffuse": { + "a": 0.27451, + "b": 1, + "g": 1, + "r": 1 + }, + "CustomMesh": { + "CastShadows": true, + "ColliderURL": "", + "Convex": true, + "CustomShader": { + "FresnelStrength": 0, + "SpecularColor": { + "b": 1, + "g": 1, + "r": 1 + }, + "SpecularIntensity": 0, + "SpecularSharpness": 2 + }, + "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/2115061845788468343/B7611EC7DCD2008B87D6518EBEFF0AD36EFE5B54/", + "MaterialIndex": 3, + "MeshURL": "https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/tuckbox_h_MSH.obj", + "NormalURL": "", + "TypeIndex": 0 + }, + "Description": "Challenge Scenario", + "DragSelectable": true, + "GMNotes": "scenarios/challenge_laid_to_rest.json", + "GUID": "e2dd57", + "Grid": true, + "GridProjection": false, + "Hands": true, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": false, + "LuaScript": "require(\"core/DownloadBox\")", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "Custom_Model", + "Nickname": "Laid to Rest", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": 12.25, + "posY": 1.5, + "posZ": -12, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 2.21, + "scaleY": 0.46, + "scaleZ": 2.42 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file From 7f826bc973d39bd27b8e81a2b0bcdcd3d23985e0 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 18 Oct 2023 22:52:12 +0200 Subject: [PATCH 64/76] updated memory bag --- .../ChallengeScenarios.9f6801.json | 8 ++++---- .../ChallengeScenarios.9f6801.luascriptstate | 2 +- .../ChallengeScenarios.9f6801/AllorNothing.72ab92.json | 6 +++--- .../ChallengeScenarios.9f6801/BadBlood.451eaa.json | 6 +++--- .../ChallengeScenarios.9f6801/BytheBook.cc7eb3.json | 4 ++-- .../ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json | 6 +++--- .../ChallengeScenarios.9f6801/ReadorDie.9e73fa.json | 2 +- .../ChallengeScenarios.9f6801/RedTideRising.5302f2.json | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json index 32939093..920cb3c3 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.json @@ -14,12 +14,12 @@ "r": 1 }, "ContainedObjects_order": [ - "BadBlood.451eaa", - "RedTideRising.5302f2", "AllorNothing.72ab92", + "BadBlood.451eaa", + "BytheBook.cc7eb3", "LaidtoRest.e2dd57", "ReadorDie.9e73fa", - "BytheBook.cc7eb3" + "RedTideRising.5302f2" ], "ContainedObjects_path": "ChallengeScenarios.9f6801", "CustomMesh": { @@ -65,7 +65,7 @@ "Tooltip": true, "Transform": { "posX": -9, - "posY": 1.481, + "posY": 1.482, "posZ": -76, "rotX": 0, "rotY": 270, diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.luascriptstate b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.luascriptstate index 609f01d1..eacd2ea5 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.luascriptstate +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801.luascriptstate @@ -1 +1 @@ -{"ml":{"451eaa":{"lock":false,"pos":{"x":12.2499580383301,"y":1.46560525894165,"z":3.98636198043823},"rot":{"x":359.920135498047,"y":269.999908447266,"z":0.016873624175787}},"5302f2":{"lock":false,"pos":{"x":12.2504663467407,"y":1.45853757858276,"z":-20.013650894165},"rot":{"x":359.920135498047,"y":270.00146484375,"z":0.0168716721236706}},"72ab92":{"lock":false,"pos":{"x":12.2520532608032,"y":1.4679582118988,"z":11.9863719940186},"rot":{"x":359.920135498047,"y":270,"z":0.0168737415224314}},"9e73fa":{"lock":false,"pos":{"x":12.2500581741333,"y":1.46089386940002,"z":-12.0136384963989},"rot":{"x":359.920135498047,"y":269.999847412109,"z":0.0168744903057814}},"cc7eb3":{"lock":false,"pos":{"x":12.2495565414429,"y":1.46325027942657,"z":-4.01364088058472},"rot":{"x":359.920135498047,"y":269.999908447266,"z":0.0168744102120399}}}} +{"ml":{"451eaa":{"lock":false,"pos":{"x":12.252,"y":1.4815,"z":11.986},"rot":{"x":0,"y":269.9999,"z":0}},"5302f2":{"lock":false,"pos":{"x":12.2505,"y":1.4815,"z":-20.0137},"rot":{"x":0,"y":270.0014,"z":0}},"72ab92":{"lock":false,"pos":{"x":12.25,"y":1.4815,"z":19.986},"rot":{"x":0,"y":269.9999,"z":0}},"9e73fa":{"lock":false,"pos":{"x":12.2501,"y":1.4815,"z":-12.0137},"rot":{"x":0,"y":269.9998,"z":0}},"cc7eb3":{"lock":false,"pos":{"x":12.25,"y":1.4815,"z":3.986},"rot":{"x":0,"y":269.9999,"z":0}},"e2dd57":{"lock":false,"pos":{"x":12.25,"y":1.4815,"z":-4.014},"rot":{"x":0,"y":270,"z":0}}}} diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/AllorNothing.72ab92.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/AllorNothing.72ab92.json index 0ed9d952..b150356e 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/AllorNothing.72ab92.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/AllorNothing.72ab92.json @@ -71,9 +71,9 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": 12.252, - "posY": 1.468, - "posZ": 11.986, + "posX": 12.25, + "posY": 1.481, + "posZ": 19.986, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BadBlood.451eaa.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BadBlood.451eaa.json index 7d1189e1..a8fe9cf7 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BadBlood.451eaa.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BadBlood.451eaa.json @@ -71,9 +71,9 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": 12.25, - "posY": 1.466, - "posZ": 3.986, + "posX": 12.252, + "posY": 1.481, + "posZ": 11.986, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BytheBook.cc7eb3.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BytheBook.cc7eb3.json index 00b94b1b..ba1c69ad 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BytheBook.cc7eb3.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/BytheBook.cc7eb3.json @@ -72,8 +72,8 @@ "Tooltip": true, "Transform": { "posX": 12.25, - "posY": 1.463, - "posZ": -4.014, + "posY": 1.481, + "posZ": 3.986, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json index a4921ec9..6750e563 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/LaidtoRest.e2dd57.json @@ -72,8 +72,8 @@ "Tooltip": true, "Transform": { "posX": 12.25, - "posY": 1.5, - "posZ": -12, + "posY": 1.481, + "posZ": -4.014, "rotX": 0, "rotY": 270, "rotZ": 0, @@ -83,4 +83,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/ReadorDie.9e73fa.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/ReadorDie.9e73fa.json index becd0521..2acce7c1 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/ReadorDie.9e73fa.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/ReadorDie.9e73fa.json @@ -72,7 +72,7 @@ "Tooltip": true, "Transform": { "posX": 12.25, - "posY": 1.461, + "posY": 1.481, "posZ": -12.014, "rotX": 0, "rotY": 270, diff --git a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/RedTideRising.5302f2.json b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/RedTideRising.5302f2.json index b794a5df..85fdb993 100644 --- a/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/RedTideRising.5302f2.json +++ b/objects/OfficialStandaloneChallengeScenarios.0ef5c8/ChallengeScenarios.9f6801/RedTideRising.5302f2.json @@ -72,7 +72,7 @@ "Tooltip": true, "Transform": { "posX": 12.25, - "posY": 1.459, + "posY": 1.481, "posZ": -20.014, "rotX": 0, "rotY": 270, From 88ca1a66f61748ddec37311fdcc1d5746bfbda27 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 00:05:21 +0200 Subject: [PATCH 65/76] fixed shiftdown vector --- src/core/token/TokenManager.ttslua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index cee5204d..fc4608b7 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -225,9 +225,11 @@ do -- Copy the offsets to make sure we don't change the static values local baseOffsets = offsets offsets = { } + + -- get a vector for the shifting (downwards local to the card) + local shiftDownVector = Vector(0, 0, shiftDown):rotateOver("y", card.getRotation().y) for i, baseOffset in ipairs(baseOffsets) do - offsets[i] = baseOffset - offsets[i][3] = offsets[i][3] + shiftDown + offsets[i] = baseOffset + shiftDownVector end end From 77bb65bfa053c9759c675704f5e02520af49a2d1 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 17:04:44 +0200 Subject: [PATCH 66/76] fixed references --- src/core/Global.ttslua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index ebf23972..9ebbbdf7 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -30,8 +30,6 @@ local NOT_INTERACTABLE = { "975c39", -- vertical border right } -local guidHandler, DATA_HELPER - -- global variable for access chaosTokens = {} local chaosTokensLastMat = nil @@ -150,7 +148,6 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") resetChaosTokenStatTracker() getModVersion() math.randomseed(os.time()) @@ -469,6 +466,7 @@ function fillContainer(args) end function getDataValue(storage, key) + local DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper") local data = DATA_HELPER.getTable(storage) if data ~= nil then local value = data[key] @@ -1005,7 +1003,7 @@ function applyOptionPanelChange(id, state) optionPanel[id] = state -- update master clue counter - local counter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MasterClueCounter" }) + local counter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "MasterClueCounter") counter.setVar("useClickableCounters", state) -- option: Play area snap tags @@ -1077,7 +1075,7 @@ end ---@param position Table Desired position of the object ---@param rotation Table Desired rotation of the object (defaults to object's rotation) function spawnHelperObject(name, position, rotation) - local sourceBag = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "OptionPanelSource" }) + local sourceBag = guidReferenceApi.getObjectByOwnerAndType("Mythos","OptionPanelSource") -- error handling for missing sourceBag if not sourceBag then From 0e6c37c4849452cc4229870fbdeb96381f959ce6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 17:07:05 +0200 Subject: [PATCH 67/76] improved readability --- objects/MasterClueCounter.4a3aa4.json | 2 +- src/core/MasterClueCounter.ttslua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/objects/MasterClueCounter.4a3aa4.json b/objects/MasterClueCounter.4a3aa4.json index c6b21615..0b1150dd 100644 --- a/objects/MasterClueCounter.4a3aa4.json +++ b/objects/MasterClueCounter.4a3aa4.json @@ -19,7 +19,7 @@ }, "ImageScalar": 1, "ImageSecondaryURL": "", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/1758068501357164917/1D06F1DC4D6888B6F57124BD2AFE20D0B0DA15A8/", + "ImageURL": "http://cloud-3.steamusercontent.com/ugc/784129913444610342/7903BA89870C1656A003FD69C79BFA99BD1AAC24/", "WidthScale": 0 }, "Description": "Click to remove all clues from all investigators", diff --git a/src/core/MasterClueCounter.ttslua b/src/core/MasterClueCounter.ttslua index 29bdef48..8f0219a8 100644 --- a/src/core/MasterClueCounter.ttslua +++ b/src/core/MasterClueCounter.ttslua @@ -20,7 +20,7 @@ function onLoad(savedData) width = 900, scale = { 1.5, 1.5, 1.5 }, font_size = 650, - font_color = { 0, 0, 0, 100 }, + font_color = { 1, 1, 1, 100 }, color = { 0, 0, 0, 0 } }) From ce38acca4f22eba8c9560b3e2435e473a6fda476 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 17:47:59 +0200 Subject: [PATCH 68/76] ui changes --- src/core/Global.ttslua | 10 ++++++++++ xml/Global/DownloadWindow.xml | 35 ++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 9ebbbdf7..6cbea48a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -717,6 +717,16 @@ function downloadCoroutine() return 1 end +-- spawns a bag that contains every object from the library +function onClick_downloadAll() + +end + +-- spawns a placeholder box for the selected object +function onClick_spawnPlaceholder() + +end + -- toggles the visibility of the respective UI ---@param player LuaPlayer Player that triggered this ---@param title String Name of the UI to toggle diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 8b11460b..49583b87 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -12,6 +12,12 @@ color="white"/> + + + fontSize="28">Download Date: Thu, 19 Oct 2023 18:20:16 +0200 Subject: [PATCH 69/76] spawn placeholder function completed --- config.json | 2 +- objects/PlaceholderBoxDummy.a93466.json | 45 ++++++++++++++ src/core/GUIDReferenceHandler.ttslua | 1 + src/core/Global.ttslua | 79 ++++++++++++++++++++----- 4 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 objects/PlaceholderBoxDummy.a93466.json diff --git a/config.json b/config.json index 1b0ebb1b..741b5115 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,6 @@ "ComponentTags_path": "ComponentTags.json", "CustomUIAssets_path": "CustomUIAssets.json", "DecalPallet_path": "DecalPallet.json", - "Decals": [], "GameComplexity": "", "GameMode": "Arkham Horror LCG - Super Complete Edition", "GameType": "", @@ -200,6 +199,7 @@ "TokenArranger.022907", "ChaosBagManager.023240", "ArkhamSCE330-1092023-Page1.964222", + "PlaceholderBoxDummy.a93466", "SoulsofDarkness.a94e6b" ], "PlayArea": 1, diff --git a/objects/PlaceholderBoxDummy.a93466.json b/objects/PlaceholderBoxDummy.a93466.json new file mode 100644 index 00000000..f20cff4f --- /dev/null +++ b/objects/PlaceholderBoxDummy.a93466.json @@ -0,0 +1,45 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "b": 0.82353, + "g": 0.20157, + "r": 0 + }, + "Description": "This dummy is there to hold the up-to-date script file for placeholder boxes to be available for placeholder box spawning.", + "DragSelectable": true, + "GMNotes": "", + "GUID": "a93466", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "require(\"core/DownloadBox\")", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "BlockRectangle", + "Nickname": "Placeholder Box Dummy", + "Snap": true, + "Sticky": true, + "Tooltip": true, + "Transform": { + "posX": 78, + "posY": 1.645, + "posZ": -33, + "rotX": 0, + "rotY": 0, + "rotZ": 0, + "scaleX": 1, + "scaleY": 1, + "scaleZ": 1 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua index b770c057..53b3c7d9 100644 --- a/src/core/GUIDReferenceHandler.ttslua +++ b/src/core/GUIDReferenceHandler.ttslua @@ -56,6 +56,7 @@ local GuidReferences = { MythosArea = "9f334f", NavigationOverlayHandler = "797ede", OptionPanelSource = "830bd0", + PlaceholderBoxDummy = "a93466", PlayArea = "721ba2", PlayAreaZone = "a2f932", PlayerCardPanel = "2d30ee", diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 6cbea48a..b7ba459b 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -724,7 +724,56 @@ end -- spawns a placeholder box for the selected object function onClick_spawnPlaceholder() + -- get object references + local item = library[contentToShow][currentListItem] + local dummy = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlaceholderBoxDummy") + + -- error handling + if not item.boxsize or item.boxsize == "" or not item.boxart or item.boxart == "" then + print("Error loading object.") + return + end + -- get data for placeholder + local spawnPos = {-39.5, 2, -87} + + local meshTable = { + big = "https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/core_h_MSH.obj", + small = "https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/tuckbox_h_MSH.obj", + wide = "http://pastebin.com/raw.php?i=uWAmuNZ2" + } + + local scaleTable = { + big = {1.00, 0.14, 1.00}, + small = {2.21, 0.46, 2.42}, + wide = {2.00, 0.11, 1.69} + } + + local placeholder = spawnObject({ + type = "Custom_Model", + position = spawnPos, + rotation = {0, 270, 0}, + scale = scaleTable[item.boxsize], + }) + + placeholder.setCustomObject({ + mesh = meshTable[item.boxsize], + diffuse = item.boxart, + material = 3 + }) + + placeholder.setColorTint({1, 1, 1, 71/255}) + placeholder.setName(item.name) + placeholder.setDescription("by " .. (item.author or "Unknown")) + placeholder.setGMNotes(item.url) + placeholder.setLuaScript(dummy.getLuaScript()) + Player.getPlayers()[1].pingTable(spawnPos) + + -- hide download window + if xmlVisibility.downloadWindow then + xmlVisibility.downloadWindow = false + UI.hide('downloadWindow') + end end -- toggles the visibility of the respective UI @@ -764,25 +813,25 @@ function updatePreviewWindow() local maskData = {} if item.boxsize == "big" then maskData = { - image = "box-cover-mask-big", - width = "870", - height = "435", - offsetXY = "154 60" - } + image = "box-cover-mask-big", + width = "870", + height = "435", + offsetXY = "154 60" + } elseif item.boxsize == "small" then maskData = { - image = "box-cover-mask-small", - width = "792", - height = "594", - offsetXY = "135 13" - } + image = "box-cover-mask-small", + width = "792", + height = "594", + offsetXY = "135 13" + } elseif item.boxsize == "wide" then maskData = { - image = "box-cover-mask-wide", - width = "756", - height = "630", - offsetXY = "-190 -70" - } + image = "box-cover-mask-wide", + width = "756", + height = "630", + offsetXY = "-190 -70" + } end -- loading empty image as placeholder until real image is loaded From 2189cf83af785f9facf426e580ce1c6cfb43c6e6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 18:47:19 +0200 Subject: [PATCH 70/76] download everything WIP --- src/core/Global.ttslua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index b7ba459b..0236fc55 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -719,7 +719,43 @@ end -- spawns a bag that contains every object from the library function onClick_downloadAll() + startLuaCoroutine(Global, "multiDownload") +end +function multiDownload() + local data = { + Name = "Bag", + Nickname = "All Downloadable Content", + Transform = { + posX = -39.5, + posY = 2, + posZ = -87, + rotX = 0, + rotY = 270, + rotZ = 0, + scaleX = 1, + scaleY = 1, + scaleZ = 1 + }, + ContainedObjects = {} + } + + -- loop through the library to add content + --for contentType, objectList in pairs(library) do + --for _, params in ipairs(objectList) do + local params = library[contentToShow][currentListItem] + WebRequest.get(SOURCE_REPO .. '/' .. params.url, function (request) + table.insert(data.ContainedObjects, request.text) + spawnObjectData({data = data}) -- need spawnObjectJson + end) + --end + --end + + -- hide download window + if xmlVisibility.downloadWindow then + xmlVisibility.downloadWindow = false + UI.hide('downloadWindow') + end end -- spawns a placeholder box for the selected object From d4d63097782479873c9ffedb484461387cb2ec39 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 23:20:46 +0200 Subject: [PATCH 71/76] added download all function --- src/core/Global.ttslua | 89 +++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0236fc55..92e088bf 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -719,43 +719,70 @@ end -- spawns a bag that contains every object from the library function onClick_downloadAll() - startLuaCoroutine(Global, "multiDownload") -end - -function multiDownload() - local data = { - Name = "Bag", - Nickname = "All Downloadable Content", - Transform = { - posX = -39.5, - posY = 2, - posZ = -87, - rotX = 0, - rotY = 270, - rotZ = 0, - scaleX = 1, - scaleY = 1, - scaleZ = 1 - }, - ContainedObjects = {} - } - - -- loop through the library to add content - --for contentType, objectList in pairs(library) do - --for _, params in ipairs(objectList) do - local params = library[contentToShow][currentListItem] - WebRequest.get(SOURCE_REPO .. '/' .. params.url, function (request) - table.insert(data.ContainedObjects, request.text) - spawnObjectData({data = data}) -- need spawnObjectJson - end) - --end - --end + broadcastToAll("Download initiated - this will take a few minutes!") -- hide download window if xmlVisibility.downloadWindow then xmlVisibility.downloadWindow = false UI.hide('downloadWindow') end + + startLuaCoroutine(Global, "coroutineDownloadAll") +end + +function coroutineDownloadAll() + local JSON = [[ + { + "Name": "Bag", + "Transform": { + "posX": -39.5, + "posY": 2, + "posZ": -87, + "rotX": 0, + "rotY": 270, + "rotZ": 0, + "scaleX": 1.0, + "scaleY": 1.0, + "scaleZ": 1.0 + }, + "Nickname": "All Downloadable Content", + "Bag": { + "Order": 0 + }, + "ContainedObjects": [ + ]] + + local contained = "" + local downloadedItems = 0 + local skippedItems = 0 + + -- loop through the library to add content + for contentType, objectList in pairs(library) do + broadcastToAll("Downloading " .. contentType .. "...") + for _, params in ipairs(objectList) do + local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url) + local start = os.time() + while true do + if request.is_done then + contained = contained .. request.text .. "," + downloadedItems = downloadedItems + 1 + break + -- time-out if item can't be loaded in 5s + elseif request.is_error or (os.time() - start) > 5 then + skippedItems = skippedItems + 1 + break + end + coroutine.yield(0) + end + end + end + + JSON = JSON .. contained .. "]}" + spawnObjectJSON({json = JSON}) + + broadcastToAll(downloadedItems .. " objects downloaded.", "Green") + broadcastToAll(skippedItems .. " objects had a time-out / error.", "Orange") + return 1 end -- spawns a placeholder box for the selected object From 31c3ebde79b928835c6188cf8712656151d032b2 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 23:31:04 +0200 Subject: [PATCH 72/76] fixed inputfield row --- .../customizable/FriendsinLowPlacesUpgradeSheet.ttslua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/playercards/customizable/FriendsinLowPlacesUpgradeSheet.ttslua b/src/playercards/customizable/FriendsinLowPlacesUpgradeSheet.ttslua index 7862666f..f0870600 100644 --- a/src/playercards/customizable/FriendsinLowPlacesUpgradeSheet.ttslua +++ b/src/playercards/customizable/FriendsinLowPlacesUpgradeSheet.ttslua @@ -25,16 +25,16 @@ customizations = { checkboxes = { posZ = -0.44, count = 2, + }, + textField = { + position = { 0.6295, 0.25, -0.44 }, + width = 290 } }, [4] = { checkboxes = { posZ = -0.05, count = 2, - }, - textField = { - position = { 0.6295, 0.25, -0.44 }, - width = 290 } }, [5] = { From bf9ba59648f71a069c70851551f0212c09d3d136 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 23:46:12 +0200 Subject: [PATCH 73/76] updated rules reference --- objects/RulesReference.d99993.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/RulesReference.d99993.json b/objects/RulesReference.d99993.json index 4de14917..efc620d1 100644 --- a/objects/RulesReference.d99993.json +++ b/objects/RulesReference.d99993.json @@ -14,7 +14,7 @@ "PDFPage": 0, "PDFPageOffset": 0, "PDFPassword": "", - "PDFUrl": "https://images-cdn.fantasyflightgames.com/filer_public/c4/b0/c4b0d66c-d79e-411b-bdb5-b5d8c457d4bc/ahc01_rules_reference_web.pdf" + "PDFUrl": "http://cloud-3.steamusercontent.com/ugc/2115061845793806189/6FC67F9AF9224452E2D8F25E63B88D702B21B0DC/" }, "Description": "", "DragSelectable": true, From 5a51752a247b47d7779cf52a36bcad06383ab342 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 20 Oct 2023 09:33:57 +0200 Subject: [PATCH 74/76] removed files --- objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json | 2 +- objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json | 2 +- objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json | 2 +- .../AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes | 8 -------- objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json | 2 +- objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json | 2 +- objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json | 2 +- objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes | 7 ------- objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json | 2 +- 18 files changed, 7 insertions(+), 85 deletions(-) delete mode 100644 objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes delete mode 100644 objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes diff --git a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes deleted file mode 100644 index ff4a7b6d..00000000 --- a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "01004-m", - "alternate_ids": [ - "01504-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json index cb81169c..809b312b 100644 --- a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json +++ b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes", + "GMNotes": "{\n \"id\": \"01004-m\",\n \"alternate_ids\": [\n \"01504-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "e53693", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes deleted file mode 100644 index 165f5f1e..00000000 --- a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "05001-m", - "alternate_ids": [ - "98010-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes deleted file mode 100644 index 7fca2d70..00000000 --- a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "01002-m", - "alternate_ids": [ - "01502-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes deleted file mode 100644 index f3e88481..00000000 --- a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "07004-m", - "alternate_ids": [ - "98016-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes deleted file mode 100644 index 11dd50a8..00000000 --- a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "02003-m", - "alternate_ids": [ - "98001-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json index 221ef1cf..9e77cd62 100644 --- a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json +++ b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes", + "GMNotes": "{\n \"id\": \"02003-m\",\n \"alternate_ids\": [\n \"98001-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "48b174", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes deleted file mode 100644 index c4d99400..00000000 --- a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "05006-m", - "alternate_ids": [ - "99001-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json index b53f0a2b..0b1a8fb4 100644 --- a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json +++ b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes", + "GMNotes": "{\n \"id\": \"05006-m\",\n \"alternate_ids\": [\n \"99001-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "b05c03", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes deleted file mode 100644 index ef45d791..00000000 --- a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "08004-m", - "alternate_ids": [ - "98007-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes deleted file mode 100644 index 9618b615..00000000 --- a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "01001-m", - "alternate_ids": [ - "98004-m", - "01501-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json index 142d258a..727af51b 100644 --- a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json +++ b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes", + "GMNotes": "{\n \"id\": \"01001-m\",\n \"alternate_ids\": [\n \"98004-m\",\n \"01501-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "5bde90", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes deleted file mode 100644 index f7c8fb25..00000000 --- a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "07005-m", - "alternate_ids": [ - "98013-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json index db19a9f6..36a280c2 100644 --- a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json +++ b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes", + "GMNotes": "{\n \"id\": \"07005-m\",\n \"alternate_ids\": [\n \"98013-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "574b59", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes deleted file mode 100644 index a835d694..00000000 --- a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "01003-m", - "alternate_ids": [ - "01503-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json index e27ecc72..d6590e3e 100644 --- a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json +++ b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes", + "GMNotes": "{\n \"id\": \"01003-m\",\n \"alternate_ids\": [\n \"01503-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "6b00ec", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes deleted file mode 100644 index 125ebf29..00000000 --- a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "01005-m", - "alternate_ids": [ - "01505-m" - ], - "type": "Minicard" -} diff --git a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json index eaada6de..47aa1b7a 100644 --- a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json +++ b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes", + "GMNotes": "{\n \"id\": \"01005-m\",\n \"alternate_ids\": [\n \"01505-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "15e40d", "Grid": true, "GridProjection": false, From ad787073f47d241241321b32f3036bc31c1c68ac Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 20 Oct 2023 09:36:55 +0200 Subject: [PATCH 75/76] more fixes --- objects/AllPlayerCards.15bb07/CarolynFern.30614e.json | 2 +- objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json | 2 +- objects/AllPlayerCards.15bb07/DexterDrake.57668a.json | 2 +- objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json index 70eab16c..7c2bfcb9 100644 --- a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json +++ b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes", + "GMNotes": "{\n \"id\": \"05001-m\",\n \"alternate_ids\": [\n \"98010-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "30614e", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json index 729d5d23..a7b0b2d4 100644 --- a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json +++ b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes", + "GMNotes": "{\n \"id\": \"01002-m\",\n \"alternate_ids\": [\n \"01502-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "bce6a5", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json index 957524e9..c6f8826f 100644 --- a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json +++ b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes", + "GMNotes": "{\n \"id\": \"07004-m\",\n \"alternate_ids\": [\n \"98016-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "57668a", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json index d01ddd38..ed8fc985 100644 --- a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json +++ b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes_path": "AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes", + "GMNotes": "{\n \"id\": \"08004-m\",\n \"alternate_ids\": [\n \"98007-m\"\n ],\n \"type\": \"Minicard\"\n}", "GUID": "a5d9bb", "Grid": true, "GridProjection": false, From c9cbff0adf3dba2539895e55f66d696807c023a1 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 20 Oct 2023 09:42:57 +0200 Subject: [PATCH 76/76] clean decompose --- modsettings/ComponentTags.json | 4 ---- objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json | 2 +- objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/CarolynFern.30614e.json | 2 +- objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json | 2 +- objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/DexterDrake.57668a.json | 2 +- objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json | 2 +- objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json | 2 +- .../AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json | 2 +- objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes | 8 ++++++++ objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json | 2 +- objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json | 2 +- objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json | 2 +- objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes | 7 +++++++ objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json | 2 +- objects/ArkhamDeckCutter.445115.json | 3 --- .../Auto-failCounter.a9a321.json | 2 +- .../ElderSignCounter.e62cb5.json | 2 +- .../Subject5U-21Helper.1335e8.json | 2 +- objects/GUIDReferenceHandler.123456.json | 2 +- objects/Playermat4Red.0840d5.json | 4 ---- 29 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes create mode 100644 objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes diff --git a/modsettings/ComponentTags.json b/modsettings/ComponentTags.json index 3e61c8d2..df092f6f 100644 --- a/modsettings/ComponentTags.json +++ b/modsettings/ComponentTags.json @@ -56,10 +56,6 @@ "displayed": "chaosBag", "normalized": "chaosbag" }, - { - "displayed": "arkham_setup_memory_object", - "normalized": "arkham_setup_memory_object" - }, { "displayed": "ActionToken", "normalized": "actiontoken" diff --git a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes new file mode 100644 index 00000000..ff4a7b6d --- /dev/null +++ b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "01004-m", + "alternate_ids": [ + "01504-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json index 809b312b..cb81169c 100644 --- a/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json +++ b/objects/AllPlayerCards.15bb07/AgnesBaker.e53693.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"01004-m\",\n \"alternate_ids\": [\n \"01504-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/AgnesBaker.e53693.gmnotes", "GUID": "e53693", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes new file mode 100644 index 00000000..165f5f1e --- /dev/null +++ b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "05001-m", + "alternate_ids": [ + "98010-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json index 7c2bfcb9..70eab16c 100644 --- a/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json +++ b/objects/AllPlayerCards.15bb07/CarolynFern.30614e.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"05001-m\",\n \"alternate_ids\": [\n \"98010-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/CarolynFern.30614e.gmnotes", "GUID": "30614e", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes new file mode 100644 index 00000000..7fca2d70 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "01002-m", + "alternate_ids": [ + "01502-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json index a7b0b2d4..729d5d23 100644 --- a/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json +++ b/objects/AllPlayerCards.15bb07/DaisyWalker.bce6a5.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"01002-m\",\n \"alternate_ids\": [\n \"01502-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/DaisyWalker.bce6a5.gmnotes", "GUID": "bce6a5", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes new file mode 100644 index 00000000..f3e88481 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "07004-m", + "alternate_ids": [ + "98016-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json index c6f8826f..957524e9 100644 --- a/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json +++ b/objects/AllPlayerCards.15bb07/DexterDrake.57668a.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"07004-m\",\n \"alternate_ids\": [\n \"98016-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/DexterDrake.57668a.gmnotes", "GUID": "57668a", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes new file mode 100644 index 00000000..11dd50a8 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "02003-m", + "alternate_ids": [ + "98001-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json index 9e77cd62..221ef1cf 100644 --- a/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json +++ b/objects/AllPlayerCards.15bb07/JennyBarnes.48b174.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"02003-m\",\n \"alternate_ids\": [\n \"98001-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/JennyBarnes.48b174.gmnotes", "GUID": "48b174", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes new file mode 100644 index 00000000..c4d99400 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "05006-m", + "alternate_ids": [ + "99001-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json index 0b1a8fb4..b53f0a2b 100644 --- a/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json +++ b/objects/AllPlayerCards.15bb07/MarieLambeau.b05c03.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"05006-m\",\n \"alternate_ids\": [\n \"99001-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/MarieLambeau.b05c03.gmnotes", "GUID": "b05c03", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes new file mode 100644 index 00000000..ef45d791 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "08004-m", + "alternate_ids": [ + "98007-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json index ed8fc985..d01ddd38 100644 --- a/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json +++ b/objects/AllPlayerCards.15bb07/NormanWithers.a5d9bb.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"08004-m\",\n \"alternate_ids\": [\n \"98007-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/NormanWithers.a5d9bb.gmnotes", "GUID": "a5d9bb", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes new file mode 100644 index 00000000..9618b615 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes @@ -0,0 +1,8 @@ +{ + "id": "01001-m", + "alternate_ids": [ + "98004-m", + "01501-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json index 727af51b..142d258a 100644 --- a/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json +++ b/objects/AllPlayerCards.15bb07/RolandBanks.5bde90.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"01001-m\",\n \"alternate_ids\": [\n \"98004-m\",\n \"01501-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/RolandBanks.5bde90.gmnotes", "GUID": "5bde90", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes new file mode 100644 index 00000000..f7c8fb25 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "07005-m", + "alternate_ids": [ + "98013-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json index 36a280c2..db19a9f6 100644 --- a/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json +++ b/objects/AllPlayerCards.15bb07/SilasMarsh.574b59.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"07005-m\",\n \"alternate_ids\": [\n \"98013-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/SilasMarsh.574b59.gmnotes", "GUID": "574b59", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes new file mode 100644 index 00000000..a835d694 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "01003-m", + "alternate_ids": [ + "01503-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json index d6590e3e..e27ecc72 100644 --- a/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json +++ b/objects/AllPlayerCards.15bb07/SkidsOToole.6b00ec.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"01003-m\",\n \"alternate_ids\": [\n \"01503-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/SkidsOToole.6b00ec.gmnotes", "GUID": "6b00ec", "Grid": true, "GridProjection": false, diff --git a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes new file mode 100644 index 00000000..125ebf29 --- /dev/null +++ b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes @@ -0,0 +1,7 @@ +{ + "id": "01005-m", + "alternate_ids": [ + "01505-m" + ], + "type": "Minicard" +} diff --git a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json index 47aa1b7a..eaada6de 100644 --- a/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json +++ b/objects/AllPlayerCards.15bb07/WendyAdams.15e40d.json @@ -24,7 +24,7 @@ }, "Description": "", "DragSelectable": true, - "GMNotes": "{\n \"id\": \"01005-m\",\n \"alternate_ids\": [\n \"01505-m\"\n ],\n \"type\": \"Minicard\"\n}", + "GMNotes_path": "AllPlayerCards.15bb07/WendyAdams.15e40d.gmnotes", "GUID": "15e40d", "Grid": true, "GridProjection": false, diff --git a/objects/ArkhamDeckCutter.445115.json b/objects/ArkhamDeckCutter.445115.json index 33d0eb4f..a34b4112 100644 --- a/objects/ArkhamDeckCutter.445115.json +++ b/objects/ArkhamDeckCutter.445115.json @@ -28,9 +28,6 @@ "Nickname": "Arkham Deck Cutter", "Snap": true, "Sticky": true, - "Tags": [ - "arkham_setup_memory_object" - ], "Tooltip": true, "Transform": { "posX": 78, diff --git a/objects/Fan-MadeAccessories.aa8b38/Auto-failCounter.a9a321.json b/objects/Fan-MadeAccessories.aa8b38/Auto-failCounter.a9a321.json index c7b63814..2c2bae63 100644 --- a/objects/Fan-MadeAccessories.aa8b38/Auto-failCounter.a9a321.json +++ b/objects/Fan-MadeAccessories.aa8b38/Auto-failCounter.a9a321.json @@ -54,4 +54,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Fan-MadeAccessories.aa8b38/ElderSignCounter.e62cb5.json b/objects/Fan-MadeAccessories.aa8b38/ElderSignCounter.e62cb5.json index bfd05186..c2460aa5 100644 --- a/objects/Fan-MadeAccessories.aa8b38/ElderSignCounter.e62cb5.json +++ b/objects/Fan-MadeAccessories.aa8b38/ElderSignCounter.e62cb5.json @@ -54,4 +54,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json b/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json index a273d326..b3b58a32 100644 --- a/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json +++ b/objects/Fan-MadeAccessories.aa8b38/Subject5U-21Helper.1335e8.json @@ -73,4 +73,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/GUIDReferenceHandler.123456.json b/objects/GUIDReferenceHandler.123456.json index 096e5e49..bd13b2f4 100644 --- a/objects/GUIDReferenceHandler.123456.json +++ b/objects/GUIDReferenceHandler.123456.json @@ -42,4 +42,4 @@ }, "Value": 0, "XmlUI": "" -} \ No newline at end of file +} diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 68a96ac7..96edae24 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -351,10 +351,6 @@ "Nickname": "Playermat 4: Red", "Snap": true, "Sticky": true, - "Tags": [ - "Red", - "Playermat" - ], "Tooltip": false, "Transform": { "posX": -30.35,