From f6d0a996742beaa7c2ef3c9f865f9bd94b2126fc Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 29 Sep 2023 11:11:38 +0200 Subject: [PATCH] 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