From 19e538fbd9f121392e854b9da9302b6cbf4a1124 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 8 Dec 2022 12:46:22 +0100 Subject: [PATCH 01/16] WIP clue counting method swapping --- objects/Custom_Model.032300.json | 2 +- objects/Custom_Model.1769ed.json | 2 +- objects/Custom_Model.37be78.json | 2 +- objects/Custom_Model.d86b7c.json | 2 +- objects/Playermat1White.8b081b.ttslua | 1 + objects/Playermat2Orange.bd0ff4.ttslua | 1 + objects/Playermat3Green.383d8b.ttslua | 1 + objects/Playermat4Red.0840d5.ttslua | 1 + src/playermat/ClueCounter.ttslua | 152 ++++++++++--------------- src/playermat/Playmat.ttslua | 35 +++++- 10 files changed, 103 insertions(+), 96 deletions(-) diff --git a/objects/Custom_Model.032300.json b/objects/Custom_Model.032300.json index edcc06c5..911a4667 100644 --- a/objects/Custom_Model.032300.json +++ b/objects/Custom_Model.032300.json @@ -52,7 +52,7 @@ "Tooltip": true, "Transform": { "posX": -31.911, - "posY": 1.57, + "posY": 1.52, "posZ": 30.97, "rotX": 0, "rotY": 0, diff --git a/objects/Custom_Model.1769ed.json b/objects/Custom_Model.1769ed.json index 823113a1..7b1fef5d 100644 --- a/objects/Custom_Model.1769ed.json +++ b/objects/Custom_Model.1769ed.json @@ -52,7 +52,7 @@ "Tooltip": true, "Transform": { "posX": -59.449, - "posY": 1.57, + "posY": 1.52, "posZ": -22.628, "rotX": 0, "rotY": 270, diff --git a/objects/Custom_Model.37be78.json b/objects/Custom_Model.37be78.json index ff90db73..21be4e19 100644 --- a/objects/Custom_Model.37be78.json +++ b/objects/Custom_Model.37be78.json @@ -52,7 +52,7 @@ "Tooltip": true, "Transform": { "posX": -18.983, - "posY": 1.57, + "posY": 1.52, "posZ": -31.01, "rotX": 0, "rotY": 180, diff --git a/objects/Custom_Model.d86b7c.json b/objects/Custom_Model.d86b7c.json index fceedaac..833cc355 100644 --- a/objects/Custom_Model.d86b7c.json +++ b/objects/Custom_Model.d86b7c.json @@ -52,7 +52,7 @@ "Tooltip": true, "Transform": { "posX": -59.499, - "posY": 1.57, + "posY": 1.52, "posZ": 9.561, "rotX": 0, "rotY": 270, diff --git a/objects/Playermat1White.8b081b.ttslua b/objects/Playermat1White.8b081b.ttslua index 0cfef19b..61f732a9 100644 --- a/objects/Playermat1White.8b081b.ttslua +++ b/objects/Playermat1White.8b081b.ttslua @@ -11,5 +11,6 @@ DISCARD_PILE_POSITION = { x = -58.9, y = 4, z = 4.29 } TRASHCAN_GUID = "147e80" STAT_TRACKER_GUID = "e598c2" RESOURCE_COUNTER_GUID = "4406f0" +CLUE_COUNTER_GUID = "d86b7c" require("playermat/Playmat") diff --git a/objects/Playermat2Orange.bd0ff4.ttslua b/objects/Playermat2Orange.bd0ff4.ttslua index f964b530..2c996e3a 100644 --- a/objects/Playermat2Orange.bd0ff4.ttslua +++ b/objects/Playermat2Orange.bd0ff4.ttslua @@ -11,5 +11,6 @@ DISCARD_PILE_POSITION = { x = -58.96, y = 4, z = -27.82 } TRASHCAN_GUID = "f7b6c8" STAT_TRACKER_GUID = "b4a5f7" RESOURCE_COUNTER_GUID = "816d84" +CLUE_COUNTER_GUID = "1769ed" require("playermat/Playmat") diff --git a/objects/Playermat3Green.383d8b.ttslua b/objects/Playermat3Green.383d8b.ttslua index 09e4e56b..255daf1f 100644 --- a/objects/Playermat3Green.383d8b.ttslua +++ b/objects/Playermat3Green.383d8b.ttslua @@ -11,5 +11,6 @@ DISCARD_PILE_POSITION = { x = -37.26, y = 4, z = 30.50 } TRASHCAN_GUID = "5f896a" STAT_TRACKER_GUID = "af7ed7" RESOURCE_COUNTER_GUID = "cd15ac" +CLUE_COUNTER_GUID = "032300" require("playermat/Playmat") diff --git a/objects/Playermat4Red.0840d5.ttslua b/objects/Playermat4Red.0840d5.ttslua index eca5aa77..a15ffc52 100644 --- a/objects/Playermat4Red.0840d5.ttslua +++ b/objects/Playermat4Red.0840d5.ttslua @@ -11,5 +11,6 @@ DISCARD_PILE_POSITION = { x = -13.78, y = 4, z = -30.48 } TRASHCAN_GUID = "4b8594" STAT_TRACKER_GUID = "e74881" RESOURCE_COUNTER_GUID = "a4b60d" +CLUE_COUNTER_GUID = "37be78" require("playermat/Playmat") diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index 08a1942f..ede426e9 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -1,91 +1,70 @@ ---Counting Bowl by MrStump - ---Table of items which can be counted in this Bowl ---Each entry has 2 things to enter - --a name (what is in the name field of that object) - --a value (how much it is worth) ---A number in the items description will override the number entry in this table -validCountItemList = { - ["Clue"] = 1, - [""] = 1, - --["Name3"] = 2, - --["Name4"] = 31, - --Add more entries as needed - --Remove the -- from before a line for the script to use it +-- Table of items which can be counted in this Bowl +-- Each entry has 2 things to enter +-- a name (what is in the name field of that object) +-- a value (how much it is worth) +-- a number in the items description will override the number entry in this table +local validCountItemList = { + ["Clue"] = 1, + [""] = 1 } - ---END OF CODE TO EDIT +local trashGUID = "70b9f6" +exposedValue = 0 function onLoad() - timerID = self.getGUID()..math.random(9999999999999) - --Sets position/color for the button, spawns it - self.createButton({ - label="", click_function="removeAllClues", function_owner=self, - position={0,0,0}, rotation={0,8,0}, height=0, width=0, - font_color={0,0,0}, font_size=2000 - }) - --Start timer which repeats forever, running countItems() every second - Timer.create({ - identifier=timerID, - function_name="countItems", function_owner=self, - repetitions=0, delay=1 - }) - exposedValue = 0 - trashCan = getObjectFromGUID("147e80") + self.createButton({ + label = "", + click_function = "removeAllClues", + function_owner = self, + position = { 0, 0.1, 0 }, + height = 0, + width = 0, + font_color = { 0, 0, 0 }, + font_size = 2000 + }) + loopID = Wait.time(countItems, 1, -1) +end + +-- Activated once per second, counts items in bowls +function countItems() + local totalValue = -1 + local countableItems = findValidItemsInSphere() + for _, entry in ipairs(countableItems) do + local descValue = tonumber(entry.hit_object.getDescription()) + local stackMult = math.abs(entry.hit_object.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 + end + end + exposedValue = totalValue + self.editButton({ index = 0, label = totalValue }) end function findValidItemsInSphere() - return filterByValidity(findItemsInSphere()) -end + local items = Physics.cast({ + origin = self.getPosition(), + direction = { 0, 1, 0 }, + type = 2, + max_distance = 0, + size = { 2, 2, 2 }, + --debug=true + }) ---Activated once per second, counts items in bowls -function countItems() - local totalValue = -1 - local countableItems = findValidItemsInSphere() - for ind, entry in ipairs(countableItems) do - local descValue = tonumber(entry.hit_object.getDescription()) - local stackMult = math.abs(entry.hit_object.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 - end + retval = {} + 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) + end end - exposedValue = totalValue - --Updates the number display - self.editButton({index=0, label=totalValue}) -end - -function filterByValidity(items) - retval = {} - 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) - end - end - end - return retval -end - - ---Gets the items in the bowl for countItems to count -function findItemsInSphere() - --Find scaling factor - local scale = self.getScale() - --Set position for the sphere - local pos = self.getPosition() - pos.y=pos.y+(1.25*scale.y) - --Ray trace to get all objects - return Physics.cast({ - origin=pos, direction={0,1,0}, type=2, max_distance=0, - size={6*scale.x,6*scale.y,6*scale.z}, --debug=true - }) + end + return retval end function removeAllClues() @@ -96,19 +75,12 @@ 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 + -- delay for animation purposes + for k = 1, 10 do coroutine.yield(0) end - trashCan.putObject(entry.hit_object) + getObjectFromGUID(trashGUID).putObject(entry.hit_object) end end - --coroutines must return a value return 1 end - -function onDestroy() - if timerID and type(timerID) == 'object' then - Timer.destroy(timerID) - end -end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 69e8912e..f6e617ab 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -675,10 +675,41 @@ function showDrawButton(visibleButton) end end --- Spawns / destroys a clickable clue counter for this playmat +-- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues ---@param clickableCounter Boolean. Whether the clickable clue counter should be present function clickableClues(clickableCounter) - print("dummy function for clue counters") + local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) + local pos = self.positionToWorld({x = -1.03, y = 0.05, z = 0.69}) + local clueCount = 0 + + if clickableCounter then + -- current clue count + clueCount = CLUE_COUNTER.getVar("exposedValue") + + -- remove clues + CLUE_COUNTER.call("removeAllClues") + + -- spawn clue counter + + -- update master clue counter + + else + -- current clue count + + -- remove clue counter + + -- spawn clues + for i = 1, clueCount do + pos.y = pos.y + 0.1 * i + spawnToken(pos, "clue") + end + + -- rotation = {x= 0, y= PLAY_ZONE_ROTATION.y + 15, z =0 } + + -- update master clue counter + + + end end -- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes From 251bf93dd4543714974e48379192d1b15849e962 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 8 Dec 2022 14:27:55 +0100 Subject: [PATCH 02/16] implementing clue counting method swap --- config.json | 13 ++-- ...el.032300.json => ClueCounter.032300.json} | 12 +-- ...el.1769ed.json => ClueCounter.1769ed.json} | 12 +-- ...el.37be78.json => ClueCounter.37be78.json} | 12 +-- ...el.d86b7c.json => ClueCounter.d86b7c.json} | 12 +-- objects/ClueCounterSwapper.d919d6.json | 77 ------------------- .../ClueCounterSwapper.d919d6.luascriptstate | 1 - .../Clues.3f22e5.json | 13 ++-- .../Clues.4111de.json | 13 ++-- .../Clues.891403.json | 13 ++-- .../Clues.db85d6.json | 13 ++-- objects/MasterClueCounter.4a3aa4.json | 2 +- objects/Playermat1White.8b081b.ttslua | 1 + objects/Playermat2Orange.bd0ff4.ttslua | 1 + objects/Playermat3Green.383d8b.ttslua | 1 + objects/Playermat4Red.0840d5.ttslua | 1 + src/core/Global.ttslua | 2 + src/core/MasterClueCounter.ttslua | 51 +++++++++--- src/playermat/Playmat.ttslua | 25 +++--- 19 files changed, 125 insertions(+), 150 deletions(-) rename objects/{Custom_Model.032300.json => ClueCounter.032300.json} (92%) rename objects/{Custom_Model.1769ed.json => ClueCounter.1769ed.json} (91%) rename objects/{Custom_Model.37be78.json => ClueCounter.37be78.json} (91%) rename objects/{Custom_Model.d86b7c.json => ClueCounter.d86b7c.json} (92%) delete mode 100644 objects/ClueCounterSwapper.d919d6.json delete mode 100644 objects/ClueCounterSwapper.d919d6.luascriptstate rename objects/{ClueCounterSwapper.d919d6 => }/Clues.3f22e5.json (90%) rename objects/{ClueCounterSwapper.d919d6 => }/Clues.4111de.json (90%) rename objects/{ClueCounterSwapper.d919d6 => }/Clues.891403.json (90%) rename objects/{ClueCounterSwapper.d919d6 => }/Clues.db85d6.json (90%) diff --git a/config.json b/config.json index dd8eb1af..ad8ed59d 100644 --- a/config.json +++ b/config.json @@ -67,6 +67,10 @@ "ScriptingTrigger.67ce9a", "Detailedphasereference.68fe54", "RulesIndex.91c83e", + "Clues.3f22e5", + "Clues.db85d6", + "Clues.891403", + "Clues.4111de", "Resources.4406f0", "Damage.eb08d6", "Horror.468e88", @@ -129,11 +133,10 @@ "LeakedItems.42cd6e", "ChaosTokenReserve.106418", "3DText.134348", - "Custom_Model.032300", - "Custom_Model.1769ed", - "Custom_Model.37be78", - "Custom_Model.d86b7c", - "ClueCounterSwapper.d919d6", + "ClueCounter.37be78", + "ClueCounter.1769ed", + "ClueCounter.032300", + "ClueCounter.d86b7c", "MasterClueCounter.4a3aa4", "LegacyAssets.7165a9", "Weaknessdecks.750fdd", diff --git a/objects/Custom_Model.032300.json b/objects/ClueCounter.032300.json similarity index 92% rename from objects/Custom_Model.032300.json rename to objects/ClueCounter.032300.json index 911a4667..506ba145 100644 --- a/objects/Custom_Model.032300.json +++ b/objects/ClueCounter.032300.json @@ -46,16 +46,16 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", - "Nickname": "", + "Nickname": "Clue Counter", "Snap": true, "Sticky": true, - "Tooltip": true, + "Tooltip": false, "Transform": { - "posX": -31.911, + "posX": -32.193, "posY": 1.52, - "posZ": 30.97, + "posZ": 30.977, "rotX": 0, - "rotY": 0, + "rotY": 10, "rotZ": 0, "scaleX": 0.33, "scaleY": 0.33, @@ -63,4 +63,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/Custom_Model.1769ed.json b/objects/ClueCounter.1769ed.json similarity index 91% rename from objects/Custom_Model.1769ed.json rename to objects/ClueCounter.1769ed.json index 7b1fef5d..7f9d652d 100644 --- a/objects/Custom_Model.1769ed.json +++ b/objects/ClueCounter.1769ed.json @@ -46,16 +46,16 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", - "Nickname": "", + "Nickname": "Clue Counter", "Snap": true, "Sticky": true, - "Tooltip": true, + "Tooltip": false, "Transform": { - "posX": -59.449, + "posX": -59.426, "posY": 1.52, - "posZ": -22.628, + "posZ": -22.721, "rotX": 0, - "rotY": 270, + "rotY": 280, "rotZ": 0, "scaleX": 0.33, "scaleY": 0.33, @@ -63,4 +63,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/Custom_Model.37be78.json b/objects/ClueCounter.37be78.json similarity index 91% rename from objects/Custom_Model.37be78.json rename to objects/ClueCounter.37be78.json index 21be4e19..a7c05ad3 100644 --- a/objects/Custom_Model.37be78.json +++ b/objects/ClueCounter.37be78.json @@ -46,16 +46,16 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", - "Nickname": "", + "Nickname": "Clue Counter", "Snap": true, "Sticky": true, - "Tooltip": true, + "Tooltip": false, "Transform": { - "posX": -18.983, + "posX": -18.87, "posY": 1.52, - "posZ": -31.01, + "posZ": -30.977, "rotX": 0, - "rotY": 180, + "rotY": 190, "rotZ": 0, "scaleX": 0.33, "scaleY": 0.33, @@ -63,4 +63,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/Custom_Model.d86b7c.json b/objects/ClueCounter.d86b7c.json similarity index 92% rename from objects/Custom_Model.d86b7c.json rename to objects/ClueCounter.d86b7c.json index 833cc355..3a6858e3 100644 --- a/objects/Custom_Model.d86b7c.json +++ b/objects/ClueCounter.d86b7c.json @@ -46,16 +46,16 @@ "LuaScriptState": "", "MeasureMovement": false, "Name": "Custom_Model", - "Nickname": "", + "Nickname": "Clue Counter", "Snap": true, "Sticky": true, - "Tooltip": true, + "Tooltip": false, "Transform": { - "posX": -59.499, + "posX": -59.426, "posY": 1.52, - "posZ": 9.561, + "posZ": 9.395, "rotX": 0, - "rotY": 270, + "rotY": 280, "rotZ": 0, "scaleX": 0.33, "scaleY": 0.33, @@ -63,4 +63,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/ClueCounterSwapper.d919d6.json b/objects/ClueCounterSwapper.d919d6.json deleted file mode 100644 index 72d1aa6e..00000000 --- a/objects/ClueCounterSwapper.d919d6.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "Bag": { - "Order": 0 - }, - "ColorDiffuse": { - "b": 1, - "g": 0.99217, - "r": 1 - }, - "ContainedObjects_order": [ - "Clues.3f22e5", - "Clues.4111de", - "Clues.891403", - "Clues.db85d6" - ], - "ContainedObjects_path": "ClueCounterSwapper.d919d6", - "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/1179328606460871995/F2AFA106E788BB456C6F9134CE7A7B14D510F973/", - "MaterialIndex": 3, - "MeshURL": "http://pastebin.com/raw.php?i=uWAmuNZ2", - "NormalURL": "", - "TypeIndex": 6 - }, - "Description": "Counter mode courtesy of tadgh's clue counter mod: https://steamcommunity.com/sharedfiles/filedetails/?id=2115363630", - "DragSelectable": true, - "GMNotes": "", - "GUID": "d919d6", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": true, - "LuaScript": "require(\"util/ClueCounterSwapper\")", - "LuaScriptState_path": "ClueCounterSwapper.d919d6.luascriptstate", - "MaterialIndex": -1, - "MeasureMovement": false, - "MeshIndex": -1, - "Name": "Custom_Model_Bag", - "Nickname": "Clue Counter Swapper", - "Snap": true, - "Sticky": true, - "Tooltip": false, - "Transform": { - "posX": -50.9, - "posY": 1.51, - "posZ": 0, - "rotX": 0, - "rotY": 270, - "rotZ": 0, - "scaleX": 0.4, - "scaleY": 0.01, - "scaleZ": 0.4 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/ClueCounterSwapper.d919d6.luascriptstate b/objects/ClueCounterSwapper.d919d6.luascriptstate deleted file mode 100644 index 42c673a6..00000000 --- a/objects/ClueCounterSwapper.d919d6.luascriptstate +++ /dev/null @@ -1 +0,0 @@ -{"ml":{"3f22e5":{"lock":true,"pos":{"x":-59.50,"y":1.54,"z":9.56},"rot":{"x":0,"y":280,"z":0}},"4111de":{"lock":true,"pos":{"x":-59.45,"y":1.54,"z":-22.63},"rot":{"x":0,"y":280,"z":0}},"891403":{"lock":true,"pos":{"x":-31.91,"y":1.54,"z":30.97},"rot":{"x":0,"y":10,"z":0}},"db85d6":{"lock":true,"pos":{"x":-18.98,"y":1.54,"z":-31.01},"rot":{"x":0,"y":190,"z":0}}}} \ No newline at end of file diff --git a/objects/ClueCounterSwapper.d919d6/Clues.3f22e5.json b/objects/Clues.3f22e5.json similarity index 90% rename from objects/ClueCounterSwapper.d919d6/Clues.3f22e5.json rename to objects/Clues.3f22e5.json index 4c3eced1..b394e586 100644 --- a/objects/ClueCounterSwapper.d919d6/Clues.3f22e5.json +++ b/objects/Clues.3f22e5.json @@ -40,13 +40,16 @@ "Nickname": "Clues", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": false, "Transform": { - "posX": -59.318, - "posY": 1.64, - "posZ": -17.674, + "posX": -59.426, + "posY": 1.3, + "posZ": -22.721, "rotX": 0, - "rotY": 270, + "rotY": 280, "rotZ": 0, "scaleX": 0.26, "scaleY": 1, @@ -54,4 +57,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/ClueCounterSwapper.d919d6/Clues.4111de.json b/objects/Clues.4111de.json similarity index 90% rename from objects/ClueCounterSwapper.d919d6/Clues.4111de.json rename to objects/Clues.4111de.json index 4d272e1a..4b8bec86 100644 --- a/objects/ClueCounterSwapper.d919d6/Clues.4111de.json +++ b/objects/Clues.4111de.json @@ -40,13 +40,16 @@ "Nickname": "Clues", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": false, "Transform": { - "posX": -23.81, - "posY": 1.589, - "posZ": -30.927, + "posX": -18.87, + "posY": 1.3, + "posZ": -30.977, "rotX": 0, - "rotY": 180, + "rotY": 190, "rotZ": 0, "scaleX": 0.26, "scaleY": 1, @@ -54,4 +57,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/ClueCounterSwapper.d919d6/Clues.891403.json b/objects/Clues.891403.json similarity index 90% rename from objects/ClueCounterSwapper.d919d6/Clues.891403.json rename to objects/Clues.891403.json index 4d4b6157..01cecada 100644 --- a/objects/ClueCounterSwapper.d919d6/Clues.891403.json +++ b/objects/Clues.891403.json @@ -40,13 +40,16 @@ "Nickname": "Clues", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": false, "Transform": { - "posX": -31.911, - "posY": 1.564, - "posZ": 30.92, + "posX": -32.193, + "posY": 1.3, + "posZ": 30.977, "rotX": 0, - "rotY": 0, + "rotY": 10, "rotZ": 0, "scaleX": 0.26, "scaleY": 1, @@ -54,4 +57,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/ClueCounterSwapper.d919d6/Clues.db85d6.json b/objects/Clues.db85d6.json similarity index 90% rename from objects/ClueCounterSwapper.d919d6/Clues.db85d6.json rename to objects/Clues.db85d6.json index 12a35cd0..4ee7f3ae 100644 --- a/objects/ClueCounterSwapper.d919d6/Clues.db85d6.json +++ b/objects/Clues.db85d6.json @@ -40,13 +40,16 @@ "Nickname": "Clues", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore" + ], "Tooltip": false, "Transform": { - "posX": -59.439, - "posY": 1.637, - "posZ": 9.472, + "posX": -59.426, + "posY": 1.3, + "posZ": 9.395, "rotX": 0, - "rotY": 270, + "rotY": 280, "rotZ": 0, "scaleX": 0.26, "scaleY": 1, @@ -54,4 +57,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/objects/MasterClueCounter.4a3aa4.json b/objects/MasterClueCounter.4a3aa4.json index 6099abb3..8ece3ec1 100644 --- a/objects/MasterClueCounter.4a3aa4.json +++ b/objects/MasterClueCounter.4a3aa4.json @@ -34,7 +34,7 @@ "LayoutGroupSortIndex": 0, "Locked": true, "LuaScript": "require(\"core/MasterClueCounter\")", - "LuaScriptState": "", + "LuaScriptState": "false", "MeasureMovement": false, "Name": "Custom_Token", "Nickname": "Master Clue Counter\n", diff --git a/objects/Playermat1White.8b081b.ttslua b/objects/Playermat1White.8b081b.ttslua index 61f732a9..f134d968 100644 --- a/objects/Playermat1White.8b081b.ttslua +++ b/objects/Playermat1White.8b081b.ttslua @@ -12,5 +12,6 @@ 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.ttslua b/objects/Playermat2Orange.bd0ff4.ttslua index 2c996e3a..ae82c4a5 100644 --- a/objects/Playermat2Orange.bd0ff4.ttslua +++ b/objects/Playermat2Orange.bd0ff4.ttslua @@ -12,5 +12,6 @@ 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.ttslua b/objects/Playermat3Green.383d8b.ttslua index 255daf1f..4d1e6bb5 100644 --- a/objects/Playermat3Green.383d8b.ttslua +++ b/objects/Playermat3Green.383d8b.ttslua @@ -12,5 +12,6 @@ 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.ttslua b/objects/Playermat4Red.0840d5.ttslua index a15ffc52..8e182e8b 100644 --- a/objects/Playermat4Red.0840d5.ttslua +++ b/objects/Playermat4Red.0840d5.ttslua @@ -12,5 +12,6 @@ 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/src/core/Global.ttslua b/src/core/Global.ttslua index a4c26687..b06ac9e5 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -632,6 +632,8 @@ function applyChange(id, state) printToAll("Clickable clue counters " .. (state and "en" or "dis") .."abled.", "White") PlayerMatAPI.clickableClues(state, "All") + -- update master clue counter + getObjectFromGUID("4a3aa4").setVar("clickableCounters", state) end end diff --git a/src/core/MasterClueCounter.ttslua b/src/core/MasterClueCounter.ttslua index ae88b0ee..c54ebc26 100644 --- a/src/core/MasterClueCounter.ttslua +++ b/src/core/MasterClueCounter.ttslua @@ -6,11 +6,27 @@ local clueCounterGUIDS = { "d86b7c" } -function onLoad() +local clueClickers = {} +local clueClickerGUIDS = { + "db85d6", + "3f22e5", + "891403", + "4111de" +} + +count = 0 +clickableCounters = false + +function onSave() return JSON.encode(clickableCounters) end + +function onLoad(savedData) + if savedData ~= nil then + clickableCounters = JSON.decode(savedData) + end self.createButton({ label = "0", click_function = "removeAllPlayerClues", - tooltip = "Click here to remove all Clues from playermats", + tooltip = "Click here to remove all collected clues", function_owner = self, position = { 0, 0.06, 0 }, height = 900, @@ -21,26 +37,41 @@ function onLoad() color = { 0, 0, 0, 0 } }) - -- loading object references to the counting bowls via GUID + -- loading object references to the clue counters / clickers via GUID for i = 1, 4 do clueCounters[i] = getObjectFromGUID(clueCounterGUIDS[i]) + clueClickers[i] = getObjectFromGUID(clueClickerGUIDS[i]) end loopID = Wait.time(sumClues, 2, -1) end --- removes all player clues by calling the respective function from the counting bowls +-- removes all player clues by calling the respective function from the counting bowls / clickers function removeAllPlayerClues() - for i = 1, 4 do - clueCounters[i].call("removeAllClues") + printToAll(count .. " clue(s) from playermats removed.", "White") + if not clickableCounters then + for i = 1, 4 do + clueCounters[i].call("removeAllClues") + end + else + for i = 1, 4 do + clueClickers[i].call("updateVal", 0) + end end + self.editButton({ index = 0, label = "0" }) end --- gets the counted values from the counting bowls and sums them up +-- gets the counted values from the counting bowls / clickers and sums them up function sumClues() - local count = 0 - for i = 1, 4 do - count = count + tonumber(clueCounters[i].getVar("exposedValue")) + count = 0 + if not clickableCounters then + for i = 1, 4 do + count = count + tonumber(clueCounters[i].getVar("exposedValue")) + end + else + for i = 1, 4 do + count = count + tonumber(clueClickers[i].getVar("val")) + end end self.editButton({ index = 0, label = tostring(count) }) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index f6e617ab..00bd2222 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -679,7 +679,8 @@ end ---@param clickableCounter Boolean. Whether the clickable clue counter should be present function clickableClues(clickableCounter) local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) - local pos = self.positionToWorld({x = -1.03, y = 0.05, z = 0.69}) + local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) + local clickerPos = CLUE_CLICKER.getPosition() local clueCount = 0 if clickableCounter then @@ -689,26 +690,26 @@ function clickableClues(clickableCounter) -- remove clues CLUE_COUNTER.call("removeAllClues") - -- spawn clue counter - - -- update master clue counter + -- set value for clue clickers + CLUE_CLICKER.call("updateVal", clueCount) + -- move clue counters up + clickerPos.y = 1.52 + CLUE_CLICKER.setPosition(clickerPos) else -- current clue count + clueCount = CLUE_CLICKER.getVar("val") - -- remove clue counter + -- move clue counters down + clickerPos.y = 1.3 + CLUE_CLICKER.setPosition(clickerPos) -- spawn clues + local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7}) for i = 1, clueCount do - pos.y = pos.y + 0.1 * i + pos.y = pos.y + 0.045 * i spawnToken(pos, "clue") end - - -- rotation = {x= 0, y= PLAY_ZONE_ROTATION.y + 15, z =0 } - - -- update master clue counter - - end end From cb0a3d42561c8da331d9d652e7c309b1266d059a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 8 Dec 2022 14:39:49 +0100 Subject: [PATCH 03/16] removing orphaned file --- src/util/ClueCounterSwapper.ttslua | 294 ----------------------------- 1 file changed, 294 deletions(-) delete mode 100644 src/util/ClueCounterSwapper.ttslua diff --git a/src/util/ClueCounterSwapper.ttslua b/src/util/ClueCounterSwapper.ttslua deleted file mode 100644 index c513e03a..00000000 --- a/src/util/ClueCounterSwapper.ttslua +++ /dev/null @@ -1,294 +0,0 @@ -function updateSave() - local data_to_save = { ["ml"] = memoryList } - saved_data = JSON.encode(data_to_save) - self.script_state = saved_data -end - -function onload(saved_data) - if saved_data ~= "" then - local loaded_data = JSON.decode(saved_data) - --Set up information off of loaded_data - memoryList = loaded_data.ml - else - --Set up information for if there is no saved saved data - memoryList = {} - end - - if next(memoryList) == nil then - createSetupButton() - else - createMemoryActionButtons() - end -end - ---Beginning Setup ---Make setup button -function createSetupButton() - self.createButton({ - label = "Setup", - click_function = "buttonClick_setup", - function_owner = self, - position = { 0, 5, -2 }, - rotation = { 0, 0, 0 }, - height = 250, - width = 600, - font_size = 150, - color = { 0, 0, 0 }, - font_color = { 1, 1, 1 } - }) -end - ---Triggered by setup button, -function buttonClick_setup() - memoryListBackup = duplicateTable(memoryList) - memoryList = {} - self.clearButtons() - createButtonsOnAllObjects() - createSetupActionButtons() -end - ---Creates selection buttons on objects -function createButtonsOnAllObjects() - local howManyButtons = 0 - for _, obj in ipairs(getAllObjects()) do - if obj ~= self then - local dummyIndex = howManyButtons - --On a normal bag, the button positions aren't the same size as the bag. - globalScaleFactor = 1.25 * 1 / self.getScale().x - --Super sweet math to set button positions - local selfPos = self.getPosition() - local objPos = obj.getPosition() - local deltaPos = findOffsetDistance(selfPos, objPos, obj) - local objPos = rotateLocalCoordinates(deltaPos, self) - objPos.x = -objPos.x * globalScaleFactor - objPos.y = objPos.y * globalScaleFactor - objPos.z = objPos.z * 4 - --Offset rotation of bag - local rot = self.getRotation() - rot.y = -rot.y + 180 - --Create function - local funcName = "selectButton_" .. howManyButtons - local func = function() buttonClick_selection(dummyIndex, obj) end - self.setVar(funcName, func) - self.createButton({ - click_function = funcName, function_owner = self, - position = objPos, rotation = rot, height = 1000, width = 1000, - color = { 0.75, 0.25, 0.25, 0.6 }, - }) - howManyButtons = howManyButtons + 1 - end - end -end - ---Creates submit and cancel buttons -function createSetupActionButtons() - self.createButton({ - label = "Cancel", click_function = "buttonClick_cancel", function_owner = self, - position = { 1.5, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 1100, - font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) - self.createButton({ - label = "Submit", click_function = "buttonClick_submit", function_owner = self, - position = { -1.2, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 1100, - font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) - self.createButton({ - label = "Reset", click_function = "buttonClick_reset", function_owner = self, - position = { -3.5, 5, 2 }, rotation = { 0, 0, 0 }, height = 350, width = 800, - font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) -end - ---During Setup ---Checks or unchecks buttons -function buttonClick_selection(index, obj) - local color = { 0, 1, 0, 0.6 } - if memoryList[obj.getGUID()] == nil then - self.editButton({ index = index, color = color }) - --Adding pos/rot to memory table - local pos, rot = obj.getPosition(), obj.getRotation() - --I need to add it like this or it won't save due to indexing issue - memoryList[obj.getGUID()] = { - pos = { x = round(pos.x, 4), y = round(pos.y, 4), z = round(pos.z, 4) }, - rot = { x = round(rot.x, 4), y = round(rot.y, 4), z = round(rot.z, 4) }, - lock = obj.getLock() - } - obj.highlightOn({ 0, 1, 0 }) - else - color = { 0.75, 0.25, 0.25, 0.6 } - self.editButton({ index = index, color = color }) - memoryList[obj.getGUID()] = nil - obj.highlightOff() - end -end - ---Cancels selection process -function buttonClick_cancel() - memoryList = memoryListBackup - self.clearButtons() - if next(memoryList) == nil then - createSetupButton() - else - createMemoryActionButtons() - end - removeAllHighlights() - broadcastToAll("Selection Canceled", { 1, 1, 1 }) -end - ---Saves selections -function buttonClick_submit() - if next(memoryList) == nil then - broadcastToAll("You cannot submit without any selections.", { 0.75, 0.25, 0.25 }) - else - self.clearButtons() - createMemoryActionButtons() - local count = 0 - for guid in pairs(memoryList) do - count = count + 1 - local obj = getObjectFromGUID(guid) - if obj ~= nil then obj.highlightOff() end - end - broadcastToAll(count .. " Objects Saved", { 1, 1, 1 }) - updateSave() - end -end - ---Resets bag to starting status -function buttonClick_reset() - memoryList = {} - self.clearButtons() - createSetupButton() - removeAllHighlights() - broadcastToAll("Tool Reset", { 1, 1, 1 }) - updateSave() -end - ---After Setup ---Creates recall and place buttons -function createMemoryActionButtons() - self.createButton({ - label = "Clicker", click_function = "buttonClick_place", function_owner = self, - position = { 4.2, 1, 0 }, rotation = { 0, 0, 0 }, height = 500, width = 1100, - font_size = 350, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) - self.createButton({ - label = "Counter", click_function = "buttonClick_recall", function_owner = self, - position = { -4.2, 1, -0.1 }, rotation = { 0, 0, 0 }, height = 500, width = 1300, - font_size = 350, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) - self.createButton({ - label = "Add Draw 1 Buttons", click_function = "addDraw1Buttons", function_owner = self, - position = { 0, 1, -2.5 }, rotation = { 0, 0, 0 }, height = 500, width = 2600, - font_size = 250, color = { 0, 0, 0 }, font_color = { 1, 1, 1 } - }) - --[[ - self.createButton({ - label="Setup", click_function="buttonClick_setup", function_owner=self, - position={-6,1,0}, rotation={0,90,0}, height=500, width=1200, - font_size=350, color={0,0,0}, font_color={1,1,1} - }) - --]] -end - -function addDraw1Buttons() - if ADD_BUTTONS_DISABLED then return end - - local mats = { "8b081b", "bd0ff4", "383d8b", "0840d5" } - for i, guid in ipairs(mats) do - local mat = getObjectFromGUID(guid) - mat.createButton({ - label = "Draw 1", - click_function = "doDrawOne", - function_owner = mat, - position = { 1.84, 0.1, -0.36 }, - scale = { 0.12, 0.12, 0.12 }, - width = 800, - height = 280, - font_size = 180 - }) - end - ADD_BUTTONS_DISABLED = true -end - ---Sends objects from bag/table to their saved position/rotation -function buttonClick_place() - local bagObjList = self.getObjects() - for guid, entry in pairs(memoryList) do - local obj = getObjectFromGUID(guid) - --If obj is out on the table, move it to the saved pos/rot - if obj ~= nil then - obj.setPositionSmooth(entry.pos) - obj.setRotationSmooth(entry.rot) - obj.setLock(entry.lock) - else - --If obj is inside of the bag - for _, bagObj in ipairs(bagObjList) do - if bagObj.guid == guid then - local item = self.takeObject({ - guid = guid, position = entry.pos, rotation = entry.rot, - }) - item.setLock(entry.lock) - break - end - end - end - end - broadcastToAll("Objects Placed", { 1, 1, 1 }) -end - ---Recalls objects to bag from table -function buttonClick_recall() - for guid, entry in pairs(memoryList) do - local obj = getObjectFromGUID(guid) - if obj ~= nil then self.putObject(obj) end - end - broadcastToAll("Objects Recalled", { 1, 1, 1 }) -end - ---Utility functions ---Find delta (difference) between 2 x/y/z coordinates -function findOffsetDistance(p1, p2, obj) - local deltaPos = {} - local bounds = obj.getBounds() - deltaPos.x = (p2.x - p1.x) - deltaPos.y = (p2.y - p1.y) + (bounds.size.y - bounds.offset.y) - deltaPos.z = (p2.z - p1.z) - return deltaPos -end - ---Used to rotate a set of coordinates by an angle -function rotateLocalCoordinates(desiredPos, obj) - local objPos, objRot = obj.getPosition(), obj.getRotation() - local angle = math.rad(objRot.y) - local x = desiredPos.x * math.cos(angle) - desiredPos.z * math.sin(angle) - local z = desiredPos.x * math.sin(angle) + desiredPos.z * math.cos(angle) - return { x = x, y = desiredPos.y, z = z } -end - ---Coroutine delay, in seconds -function wait(time) - local start = os.time() - repeat coroutine.yield(0) until os.time() > start + time -end - ---Duplicates a table (needed to prevent it making reference to the same objects) -function duplicateTable(oldTable) - local newTable = {} - for k, v in pairs(oldTable) do - newTable[k] = v - end - return newTable -end - ---Moves scripted highlight from all objects -function removeAllHighlights() - for _, obj in ipairs(getAllObjects()) do - obj.highlightOff() - end -end - ---Round number (num) to the Nth decimal (dec) -function round(num, dec) - local mult = 10 ^ (dec or 0) - return math.floor(num * mult + 0.5) / mult -end From d42691b9d5f04d2fa95d49e6b6683a655bd70e2e Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 14 Dec 2022 16:34:27 +0100 Subject: [PATCH 04/16] coordinate cleaning and set aside snap points --- modsettings/SnapPoints.json | 114 ++++++++++++++++++- objects/Custom_Tile.9f334f.json | 2 +- objects/InvestigatorSkillTracker.af7ed7.json | 4 +- objects/InvestigatorSkillTracker.b4a5f7.json | 2 +- objects/InvestigatorSkillTracker.e598c2.json | 2 +- objects/InvestigatorSkillTracker.e74881.json | 4 +- objects/LolaNeutral.460250.json | 4 +- objects/LolaNeutral.637e17.json | 4 +- objects/LolaNeutral.719ff4.json | 4 +- objects/LolaNeutral.7ffb43.json | 4 +- objects/LolaNeutral.8a496e.json | 4 +- objects/LolaNeutral.9312d8.json | 4 +- objects/LolaNeutral.a1e2a3.json | 4 +- objects/LolaNeutral.b8409d.json | 4 +- objects/LolaNeutral.bfcaf4.json | 4 +- objects/LolaNeutral.d7910b.json | 4 +- objects/LolaNeutral.e003fe.json | 4 +- objects/LolaNeutral.e1ab8d.json | 4 +- objects/Playermat1White.8b081b.json | 4 +- objects/Playermat3Green.383d8b.json | 4 +- objects/Playermat4Red.0840d5.json | 4 +- objects/ScriptingTrigger.18538f.json | 4 +- objects/ScriptingTrigger.7af2cf.json | 2 +- objects/ScriptingTrigger.b047f8.json | 4 +- objects/ScriptingTrigger.fb28e1.json | 4 +- objects/Trash.70b9f6.json | 2 +- 26 files changed, 158 insertions(+), 46 deletions(-) diff --git a/modsettings/SnapPoints.json b/modsettings/SnapPoints.json index 2e5f3855..5a22fa37 100644 --- a/modsettings/SnapPoints.json +++ b/modsettings/SnapPoints.json @@ -4203,5 +4203,117 @@ "y": 1.481, "z": 14.5 } + }, + { + "Position": { + "x": -50.25, + "y": 1.481, + "z": 30.9 + } + }, + { + "Position": { + "x": -53.42, + "y": 1.481, + "z": 30.9 + } + }, + { + "Position": { + "x": -56.58, + "y": 1.481, + "z": 30.9 + } + }, + { + "Position": { + "x": -59.74, + "y": 1.481, + "z": 30.9 + } + }, + { + "Position": { + "x": -50.25, + "y": 1.481, + "z": -30.9 + } + }, + { + "Position": { + "x": -53.42, + "y": 1.481, + "z": -30.9 + } + }, + { + "Position": { + "x": -56.58, + "y": 1.481, + "z": -30.9 + } + }, + { + "Position": { + "x": -59.74, + "y": 1.481, + "z": -30.9 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": -21.85 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": -25.0 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": -28.17 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": -31.34 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": 21.85 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": 25.0 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": 28.17 + } + }, + { + "Position": { + "x": -10.8, + "y": 1.481, + "z": 31.34 + } } -] \ No newline at end of file +] diff --git a/objects/Custom_Tile.9f334f.json b/objects/Custom_Tile.9f334f.json index c50944a6..4dbc5e5c 100644 --- a/objects/Custom_Tile.9f334f.json +++ b/objects/Custom_Tile.9f334f.json @@ -70,7 +70,7 @@ "Transform": { "posX": -1.309, "posY": 1.483, - "posZ": 0.034, + "posZ": 0, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/InvestigatorSkillTracker.af7ed7.json b/objects/InvestigatorSkillTracker.af7ed7.json index 5478829f..b750e89c 100644 --- a/objects/InvestigatorSkillTracker.af7ed7.json +++ b/objects/InvestigatorSkillTracker.af7ed7.json @@ -46,9 +46,9 @@ ], "Tooltip": true, "Transform": { - "posX": -32.588, + "posX": -32.6, "posY": 1.531, - "posZ": 19.301, + "posZ": 19.35, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/InvestigatorSkillTracker.b4a5f7.json b/objects/InvestigatorSkillTracker.b4a5f7.json index 7d10b298..c1b575f9 100644 --- a/objects/InvestigatorSkillTracker.b4a5f7.json +++ b/objects/InvestigatorSkillTracker.b4a5f7.json @@ -48,7 +48,7 @@ "Transform": { "posX": -47.76, "posY": 1.531, - "posZ": -23.116, + "posZ": -23.1, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/InvestigatorSkillTracker.e598c2.json b/objects/InvestigatorSkillTracker.e598c2.json index 2d45c21c..c82d17bf 100644 --- a/objects/InvestigatorSkillTracker.e598c2.json +++ b/objects/InvestigatorSkillTracker.e598c2.json @@ -48,7 +48,7 @@ "Transform": { "posX": -47.75, "posY": 1.531, - "posZ": 9, + "posZ": 9.1, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/InvestigatorSkillTracker.e74881.json b/objects/InvestigatorSkillTracker.e74881.json index 2b884e4e..d6643109 100644 --- a/objects/InvestigatorSkillTracker.e74881.json +++ b/objects/InvestigatorSkillTracker.e74881.json @@ -46,9 +46,9 @@ ], "Tooltip": true, "Transform": { - "posX": -18.475, + "posX": -18.6, "posY": 1.531, - "posZ": -19.301, + "posZ": -19.35, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/LolaNeutral.460250.json b/objects/LolaNeutral.460250.json index 4f27f272..21d24b63 100644 --- a/objects/LolaNeutral.460250.json +++ b/objects/LolaNeutral.460250.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -19.06, + "posX": -19.17, "posY": 1.55, - "posZ": -24.78, + "posZ": -24.845, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/LolaNeutral.637e17.json b/objects/LolaNeutral.637e17.json index 8fde73cd..b36f23e3 100644 --- a/objects/LolaNeutral.637e17.json +++ b/objects/LolaNeutral.637e17.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.206, + "posX": -53.219, "posY": 1.55, - "posZ": 8.432, + "posZ": 8.513, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/LolaNeutral.719ff4.json b/objects/LolaNeutral.719ff4.json index 3aa0626e..9899146d 100644 --- a/objects/LolaNeutral.719ff4.json +++ b/objects/LolaNeutral.719ff4.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.206, + "posX": -53.219, "posY": 1.55, - "posZ": 9.573, + "posZ": 9.657, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/LolaNeutral.7ffb43.json b/objects/LolaNeutral.7ffb43.json index adf4cd95..f87b6f78 100644 --- a/objects/LolaNeutral.7ffb43.json +++ b/objects/LolaNeutral.7ffb43.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -34.264, + "posX": -34.293, "posY": 1.55, - "posZ": 24.8, + "posZ": 24.864, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/LolaNeutral.8a496e.json b/objects/LolaNeutral.8a496e.json index 980c4f50..8fd38182 100644 --- a/objects/LolaNeutral.8a496e.json +++ b/objects/LolaNeutral.8a496e.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.265, + "posX": -53.269, "posY": 1.55, - "posZ": -22.542, + "posZ": -22.541, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/LolaNeutral.9312d8.json b/objects/LolaNeutral.9312d8.json index 48d450fe..c8917ec7 100644 --- a/objects/LolaNeutral.9312d8.json +++ b/objects/LolaNeutral.9312d8.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.265, + "posX": -53.269, "posY": 1.55, - "posZ": -24.825, + "posZ": -24.824, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/LolaNeutral.a1e2a3.json b/objects/LolaNeutral.a1e2a3.json index 7370d73a..cedc49b2 100644 --- a/objects/LolaNeutral.a1e2a3.json +++ b/objects/LolaNeutral.a1e2a3.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -17.918, + "posX": -18.025, "posY": 1.55, - "posZ": -24.783, + "posZ": -24.845, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/LolaNeutral.b8409d.json b/objects/LolaNeutral.b8409d.json index 81c33a49..e01f8186 100644 --- a/objects/LolaNeutral.b8409d.json +++ b/objects/LolaNeutral.b8409d.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -31.981, + "posX": -32.011, "posY": 1.55, - "posZ": 24.8, + "posZ": 24.864, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/LolaNeutral.bfcaf4.json b/objects/LolaNeutral.bfcaf4.json index 089ce311..b0b1021b 100644 --- a/objects/LolaNeutral.bfcaf4.json +++ b/objects/LolaNeutral.bfcaf4.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -16.777, + "posX": -16.887, "posY": 1.55, - "posZ": -24.783, + "posZ": -24.845, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/LolaNeutral.d7910b.json b/objects/LolaNeutral.d7910b.json index 575f17a8..91f903e4 100644 --- a/objects/LolaNeutral.d7910b.json +++ b/objects/LolaNeutral.d7910b.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -33.123, + "posX": -33.149, "posY": 1.55, - "posZ": 24.8, + "posZ": 24.864, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/LolaNeutral.e003fe.json b/objects/LolaNeutral.e003fe.json index 8d973e6e..fec8c7d4 100644 --- a/objects/LolaNeutral.e003fe.json +++ b/objects/LolaNeutral.e003fe.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.206, + "posX": -53.219, "posY": 1.55, - "posZ": 7.29, + "posZ": 7.374, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/LolaNeutral.e1ab8d.json b/objects/LolaNeutral.e1ab8d.json index dc05a5eb..93653a2e 100644 --- a/objects/LolaNeutral.e1ab8d.json +++ b/objects/LolaNeutral.e1ab8d.json @@ -1157,9 +1157,9 @@ ], "Tooltip": true, "Transform": { - "posX": -53.265, + "posX": -53.269, "posY": 1.55, - "posZ": -23.683, + "posZ": -23.679, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index c6f3c0d5..9ddd84f6 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -282,9 +282,9 @@ "Sticky": true, "Tooltip": false, "Transform": { - "posX": -54.989, + "posX": -55, "posY": 1.45, - "posZ": 16.018, + "posZ": 16.1, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index 68d6c1f0..340f8771 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -282,9 +282,9 @@ "Sticky": true, "Tooltip": false, "Transform": { - "posX": -25.57, + "posX": -25.6, "posY": 1.45, - "posZ": 26.54, + "posZ": 26.6, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index a02e4169..18d8515e 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -282,9 +282,9 @@ "Sticky": true, "Tooltip": false, "Transform": { - "posX": -25.493, + "posX": -25.6, "posY": 1.45, - "posZ": -26.54, + "posZ": -26.6, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/ScriptingTrigger.18538f.json b/objects/ScriptingTrigger.18538f.json index eb8d336e..03a8eebc 100644 --- a/objects/ScriptingTrigger.18538f.json +++ b/objects/ScriptingTrigger.18538f.json @@ -31,9 +31,9 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": -13.738, + "posX": -14.05, "posY": 1.481, - "posZ": -28.511, + "posZ": -28.6, "rotX": 0, "rotY": 180, "rotZ": 0, diff --git a/objects/ScriptingTrigger.7af2cf.json b/objects/ScriptingTrigger.7af2cf.json index e906abce..cce12e37 100644 --- a/objects/ScriptingTrigger.7af2cf.json +++ b/objects/ScriptingTrigger.7af2cf.json @@ -31,7 +31,7 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": -56.926, + "posX": -57, "posY": 1.544, "posZ": 4.545, "rotX": 0, diff --git a/objects/ScriptingTrigger.b047f8.json b/objects/ScriptingTrigger.b047f8.json index c9c914cc..fb645665 100644 --- a/objects/ScriptingTrigger.b047f8.json +++ b/objects/ScriptingTrigger.b047f8.json @@ -31,9 +31,9 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": -56.928, + "posX": -57, "posY": 1.539, - "posZ": -27.729, + "posZ": -27.65, "rotX": 0, "rotY": 270, "rotZ": 0, diff --git a/objects/ScriptingTrigger.fb28e1.json b/objects/ScriptingTrigger.fb28e1.json index e3bc2abe..f0d9ec82 100644 --- a/objects/ScriptingTrigger.fb28e1.json +++ b/objects/ScriptingTrigger.fb28e1.json @@ -31,9 +31,9 @@ "Sticky": true, "Tooltip": true, "Transform": { - "posX": -36.964, + "posX": -37.15, "posY": 1.468, - "posZ": 28.475, + "posZ": 28.6, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/objects/Trash.70b9f6.json b/objects/Trash.70b9f6.json index 87ab449e..8efdd284 100644 --- a/objects/Trash.70b9f6.json +++ b/objects/Trash.70b9f6.json @@ -48,7 +48,7 @@ "Transform": { "posX": 0.493, "posY": 1.656, - "posZ": 0.023, + "posZ": 0, "rotX": 0, "rotY": 0, "rotZ": 0, From d47bc0845abcbd3e23c93a856e33e23f77e9b44b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 15 Dec 2022 00:18:10 +0100 Subject: [PATCH 05/16] resolving comments --- .../CleanUpHelper.26cf4b.ttslua | 2 +- src/core/Global.ttslua | 2 +- src/core/MasterClueCounter.ttslua | 18 +++++++++--------- src/playermat/ClueCounter.ttslua | 2 -- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua index ee45b959..8097141f 100644 --- a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua @@ -210,7 +210,7 @@ function resetCounters() -- reset doom on agenda local doomcounter = getObjectFromGUID("85c4c6") if doomcounter ~= nil then - doomcounter.call("updateVal") + doomcounter.call("updateVal", 0) end for i, guid in ipairs(TRACKER_GUIDS) do diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index c0619fb5..e415346f 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -676,7 +676,7 @@ function applyOptionPanelChange(id, state) playmatAPI.clickableClues(state, "All") -- update master clue counter - getObjectFromGUID("4a3aa4").setVar("clickableCounters", state) + getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state) end end diff --git a/src/core/MasterClueCounter.ttslua b/src/core/MasterClueCounter.ttslua index c54ebc26..71e314e9 100644 --- a/src/core/MasterClueCounter.ttslua +++ b/src/core/MasterClueCounter.ttslua @@ -15,13 +15,13 @@ local clueClickerGUIDS = { } count = 0 -clickableCounters = false +useClickableCounters = false -function onSave() return JSON.encode(clickableCounters) end +function onSave() return JSON.encode(useClickableCounters) end function onLoad(savedData) if savedData ~= nil then - clickableCounters = JSON.decode(savedData) + useClickableCounters = JSON.decode(savedData) end self.createButton({ label = "0", @@ -49,13 +49,13 @@ end -- removes all player clues by calling the respective function from the counting bowls / clickers function removeAllPlayerClues() printToAll(count .. " clue(s) from playermats removed.", "White") - if not clickableCounters then + if useClickableCounters then for i = 1, 4 do - clueCounters[i].call("removeAllClues") + clueClickers[i].call("updateVal", 0) end else for i = 1, 4 do - clueClickers[i].call("updateVal", 0) + clueCounters[i].call("removeAllClues") end end self.editButton({ index = 0, label = "0" }) @@ -64,13 +64,13 @@ end -- gets the counted values from the counting bowls / clickers and sums them up function sumClues() count = 0 - if not clickableCounters then + if useClickableCounters then for i = 1, 4 do - count = count + tonumber(clueCounters[i].getVar("exposedValue")) + count = count + tonumber(clueClickers[i].getVar("val")) end else for i = 1, 4 do - count = count + tonumber(clueClickers[i].getVar("val")) + count = count + tonumber(clueCounters[i].getVar("exposedValue")) end end self.editButton({ index = 0, label = tostring(count) }) diff --git a/src/playermat/ClueCounter.ttslua b/src/playermat/ClueCounter.ttslua index de94297c..ede426e9 100644 --- a/src/playermat/ClueCounter.ttslua +++ b/src/playermat/ClueCounter.ttslua @@ -9,8 +9,6 @@ local validCountItemList = { } local trashGUID = "70b9f6" exposedValue = 0 -local trashGUID = "70b9f6" -exposedValue = 0 function onLoad() self.createButton({ From bbd915122745ef8f8aad0fafe61897f5e2692368 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 15 Dec 2022 02:26:38 +0100 Subject: [PATCH 06/16] moving clue handling to playermatapi --- src/core/MasterClueCounter.ttslua | 44 +++---------------------------- src/playermat/Playmat.ttslua | 26 +++++++++++++++++- src/playermat/PlaymatApi.ttslua | 36 +++++++++++++++++++++++-- xml/Global.xml | 2 +- 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/core/MasterClueCounter.ttslua b/src/core/MasterClueCounter.ttslua index 71e314e9..574362b3 100644 --- a/src/core/MasterClueCounter.ttslua +++ b/src/core/MasterClueCounter.ttslua @@ -1,22 +1,7 @@ -local clueCounters = {} -local clueCounterGUIDS = { - "37be78", - "1769ed", - "032300", - "d86b7c" -} - -local clueClickers = {} -local clueClickerGUIDS = { - "db85d6", - "3f22e5", - "891403", - "4111de" -} - count = 0 useClickableCounters = false +local playmatAPI = require("playermat/PlaymatApi") function onSave() return JSON.encode(useClickableCounters) end function onLoad(savedData) @@ -37,41 +22,18 @@ function onLoad(savedData) color = { 0, 0, 0, 0 } }) - -- loading object references to the clue counters / clickers via GUID - for i = 1, 4 do - clueCounters[i] = getObjectFromGUID(clueCounterGUIDS[i]) - clueClickers[i] = getObjectFromGUID(clueClickerGUIDS[i]) - end - loopID = Wait.time(sumClues, 2, -1) end -- removes all player clues by calling the respective function from the counting bowls / clickers function removeAllPlayerClues() printToAll(count .. " clue(s) from playermats removed.", "White") - if useClickableCounters then - for i = 1, 4 do - clueClickers[i].call("updateVal", 0) - end - else - for i = 1, 4 do - clueCounters[i].call("removeAllClues") - end - end + playmatAPI.removeClues("All") self.editButton({ index = 0, label = "0" }) end -- gets the counted values from the counting bowls / clickers and sums them up function sumClues() - count = 0 - if useClickableCounters then - for i = 1, 4 do - count = count + tonumber(clueClickers[i].getVar("val")) - end - else - for i = 1, 4 do - count = count + tonumber(clueCounters[i].getVar("exposedValue")) - end - end + count = playmatAPI.getClueCount(useClickableCounters, "All") self.editButton({ index = 0, label = tostring(count) }) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 35ec0f09..c5902e71 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -689,7 +689,7 @@ function showDrawButton(visible) 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 +---@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) @@ -726,6 +726,30 @@ function clickableClues(showCounter) end 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) + + CLUE_COUNTER.call("removeAllClues") + CLUE_CLICKER.call("updateVal", 0) +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 + local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) + count = tonumber(CLUE_CLICKER.getVar("val")) + else + local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) + count = tonumber(CLUE_COUNTER.getVar("exposedValue")) + end + return count +end + -- Sets this playermat'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 diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 3b71b962..ba6f1687 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -6,7 +6,21 @@ do White = "8b081b", Orange = "bd0ff4", Green = "383d8b", - Red = "0840d5", + Red = "0840d5" + } + + local CLUE_COUNTER_GUIDS = { + White = "37be78", + Orange = "1769ed", + Green = "032300", + Red = "d86b7c" + } + + local CLUE_CLICKER_GUIDS = { + White = "db85d6", + Orange = "3f22e5", + Green = "891403", + Red = "4111de" } -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If @@ -23,7 +37,6 @@ do 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 @@ -44,6 +57,25 @@ do 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. + PlaymatApi.removeClues = function(matColor) + for _, mat in ipairs(internal.getMatForColor(matColor)) do + mat.call("removeClues") + end + end + + -- Reports the clue count for the requested playermat + ---@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 + count = count + tonumber(mat.call("getClueCount", useClickableCounters)) + end + return count + 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. diff --git a/xml/Global.xml b/xml/Global.xml index ebb4622f..69935cd5 100644 --- a/xml/Global.xml +++ b/xml/Global.xml @@ -17,7 +17,7 @@