From a88a774dc096e90c6f130dbad26b73792ba92b28 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 23 Oct 2023 16:07:21 +0200 Subject: [PATCH] changed approach --- config.json | 7 ++-- objects/TokenDiscardZone.457de3.json | 46 +++++++++++++++++++++ objects/TokenDiscardZone.457de4.json | 46 +++++++++++++++++++++ objects/TokenDiscardZone.457de5.json | 46 +++++++++++++++++++++ objects/TokenDiscardZone.457de6.json | 46 +++++++++++++++++++++ objects/TokenRemover.0a5a29.json | 60 ---------------------------- objects/TokenRemover.2ba7a5.json | 60 ---------------------------- objects/TokenRemover.39b175.json | 60 ---------------------------- src/core/GUIDReferenceHandler.ttslua | 4 ++ src/core/Global.ttslua | 22 ++++++++++ src/playermat/Playmat.ttslua | 22 ---------- src/util/TokenRemover.ttslua | 52 ------------------------ 12 files changed, 214 insertions(+), 257 deletions(-) create mode 100644 objects/TokenDiscardZone.457de3.json create mode 100644 objects/TokenDiscardZone.457de4.json create mode 100644 objects/TokenDiscardZone.457de5.json create mode 100644 objects/TokenDiscardZone.457de6.json delete mode 100644 objects/TokenRemover.0a5a29.json delete mode 100644 objects/TokenRemover.2ba7a5.json delete mode 100644 objects/TokenRemover.39b175.json delete mode 100644 src/util/TokenRemover.ttslua diff --git a/config.json b/config.json index e1e364ce..7662c491 100644 --- a/config.json +++ b/config.json @@ -107,7 +107,6 @@ "ChaosBagStatTracker.766620", "Blesstokens.afa06b", "Cursetokens.bd0253", - "TokenRemover.0a5a29", "TokenSpawnTool.36b4ee", "OfficialStandaloneChallengeScenarios.0ef5c8", "TarotDeck.77f1e5", @@ -174,8 +173,10 @@ "GameData.3dbe47", "SCEDTour.0e5aa8", "PlayerCards.2d30ee", - "TokenRemover.39b175", - "TokenRemover.2ba7a5", + "TokenDiscardZone.457de3", + "TokenDiscardZone.457de4", + "TokenDiscardZone.457de5", + "TokenDiscardZone.457de6", "Decoration-Map.6161b4", "RulebooksGuidesandTablets.fcfa7f", "TableDivider.612072", diff --git a/objects/TokenDiscardZone.457de3.json b/objects/TokenDiscardZone.457de3.json new file mode 100644 index 00000000..9062944f --- /dev/null +++ b/objects/TokenDiscardZone.457de3.json @@ -0,0 +1,46 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "a": 0.5098, + "b": 1, + "g": 1, + "r": 1 + }, + "Description": "", + "DragSelectable": true, + "GMNotes": "", + "GUID": "457de3", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "ScriptingTrigger", + "Nickname": "TokenDiscardZone", + "Snap": true, + "Sticky": true, + "Tooltip": false, + "Transform": { + "posX": -65, + "posY": 1.5, + "posZ": 16.1, + "rotX": 0, + "rotY": 90, + "rotZ": 0, + "scaleX": 22, + "scaleY": 0.5, + "scaleZ": 5 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/objects/TokenDiscardZone.457de4.json b/objects/TokenDiscardZone.457de4.json new file mode 100644 index 00000000..991c9200 --- /dev/null +++ b/objects/TokenDiscardZone.457de4.json @@ -0,0 +1,46 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "a": 0.5098, + "b": 1, + "g": 1, + "r": 1 + }, + "Description": "", + "DragSelectable": true, + "GMNotes": "", + "GUID": "457de4", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "ScriptingTrigger", + "Nickname": "TokenDiscardZone", + "Snap": true, + "Sticky": true, + "Tooltip": false, + "Transform": { + "posX": -65, + "posY": 1.5, + "posZ": -16.1, + "rotX": 0, + "rotY": 90, + "rotZ": 0, + "scaleX": 22, + "scaleY": 0.5, + "scaleZ": 5 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/objects/TokenDiscardZone.457de5.json b/objects/TokenDiscardZone.457de5.json new file mode 100644 index 00000000..2a85afc9 --- /dev/null +++ b/objects/TokenDiscardZone.457de5.json @@ -0,0 +1,46 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "a": 0.5098, + "b": 1, + "g": 1, + "r": 1 + }, + "Description": "", + "DragSelectable": true, + "GMNotes": "", + "GUID": "457de5", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "ScriptingTrigger", + "Nickname": "TokenDiscardZone", + "Snap": true, + "Sticky": true, + "Tooltip": false, + "Transform": { + "posX": -30.35, + "posY": 1.5, + "posZ": 36.6, + "rotX": 0, + "rotY": 180, + "rotZ": 0, + "scaleX": 22, + "scaleY": 0.5, + "scaleZ": 5 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/objects/TokenDiscardZone.457de6.json b/objects/TokenDiscardZone.457de6.json new file mode 100644 index 00000000..5100327c --- /dev/null +++ b/objects/TokenDiscardZone.457de6.json @@ -0,0 +1,46 @@ +{ + "AltLookAngle": { + "x": 0, + "y": 0, + "z": 0 + }, + "Autoraise": true, + "ColorDiffuse": { + "a": 0.5098, + "b": 1, + "g": 1, + "r": 1 + }, + "Description": "", + "DragSelectable": true, + "GMNotes": "", + "GUID": "457de6", + "Grid": true, + "GridProjection": false, + "Hands": false, + "HideWhenFaceDown": false, + "IgnoreFoW": false, + "LayoutGroupSortIndex": 0, + "Locked": true, + "LuaScript": "", + "LuaScriptState": "", + "MeasureMovement": false, + "Name": "ScriptingTrigger", + "Nickname": "TokenDiscardZone", + "Snap": true, + "Sticky": true, + "Tooltip": false, + "Transform": { + "posX": -30.35, + "posY": 1.5, + "posZ": -36.6, + "rotX": 0, + "rotY": 0, + "rotZ": 0, + "scaleX": 22, + "scaleY": 0.5, + "scaleZ": 5 + }, + "Value": 0, + "XmlUI": "" +} \ No newline at end of file diff --git a/objects/TokenRemover.0a5a29.json b/objects/TokenRemover.0a5a29.json deleted file mode 100644 index c47ef417..00000000 --- a/objects/TokenRemover.0a5a29.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "CustomImage": { - "CustomTile": { - "Stackable": false, - "Stretch": true, - "Thickness": 0.1, - "Type": 0 - }, - "ImageScalar": 1, - "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728653004/7BD6E4B8763FE70DB6ADB22B62504361D3778309/", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728651946/04A700179A71859B828E30D2877D802749B8223C/", - "WidthScale": 0 - }, - "Description": "See Notebook for details.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "0a5a29", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": true, - "LuaScript": "require(\"util/TokenRemover\")", - "LuaScriptState": "null", - "MeasureMovement": false, - "Name": "Custom_Tile", - "Nickname": "Token Remover", - "Snap": true, - "Sticky": true, - "Tags": [ - "CleanUpHelper_ignore" - ], - "Tooltip": true, - "Transform": { - "posX": -58.5, - "posY": 1.481, - "posZ": 0, - "rotX": 0, - "rotY": 270, - "rotZ": 0, - "scaleX": 1, - "scaleY": 1, - "scaleZ": 1 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/TokenRemover.2ba7a5.json b/objects/TokenRemover.2ba7a5.json deleted file mode 100644 index 218af5f6..00000000 --- a/objects/TokenRemover.2ba7a5.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "CustomImage": { - "CustomTile": { - "Stackable": false, - "Stretch": true, - "Thickness": 0.1, - "Type": 0 - }, - "ImageScalar": 1, - "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728653004/7BD6E4B8763FE70DB6ADB22B62504361D3778309/", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728651946/04A700179A71859B828E30D2877D802749B8223C/", - "WidthScale": 0 - }, - "Description": "See Notebook for details.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "2ba7a5", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": true, - "LuaScript": "require(\"util/TokenRemover\")", - "LuaScriptState": "null", - "MeasureMovement": false, - "Name": "Custom_Tile", - "Nickname": "Token Remover", - "Snap": true, - "Sticky": true, - "Tags": [ - "CleanUpHelper_ignore" - ], - "Tooltip": true, - "Transform": { - "posX": -45.3, - "posY": 1.481, - "posZ": 29.735, - "rotX": 0, - "rotY": 0, - "rotZ": 0, - "scaleX": 0.8, - "scaleY": 1, - "scaleZ": 0.8 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/TokenRemover.39b175.json b/objects/TokenRemover.39b175.json deleted file mode 100644 index 4a74bb1b..00000000 --- a/objects/TokenRemover.39b175.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "CustomImage": { - "CustomTile": { - "Stackable": false, - "Stretch": true, - "Thickness": 0.1, - "Type": 0 - }, - "ImageScalar": 1, - "ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728653004/7BD6E4B8763FE70DB6ADB22B62504361D3778309/", - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/1767069252728651946/04A700179A71859B828E30D2877D802749B8223C/", - "WidthScale": 0 - }, - "Description": "See Notebook for details.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "39b175", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": true, - "LuaScript": "require(\"util/TokenRemover\")", - "LuaScriptState": "null", - "MeasureMovement": false, - "Name": "Custom_Tile", - "Nickname": "Token Remover", - "Snap": true, - "Sticky": true, - "Tags": [ - "CleanUpHelper_ignore" - ], - "Tooltip": true, - "Transform": { - "posX": -45.299, - "posY": 1.481, - "posZ": -30.309, - "rotX": 0, - "rotY": 180, - "rotZ": 0, - "scaleX": 0.8, - "scaleY": 1, - "scaleZ": 0.8 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua index 53b3c7d9..6aa81cd8 100644 --- a/src/core/GUIDReferenceHandler.ttslua +++ b/src/core/GUIDReferenceHandler.ttslua @@ -8,6 +8,7 @@ local GuidReferences = { InvestigatorSkillTracker = "e598c2", Playermat = "8b081b", ResourceCounter = "4406f0", + TokenDiscardZone = "457de3", Trash = "147e80" }, Orange = { @@ -19,6 +20,7 @@ local GuidReferences = { InvestigatorSkillTracker = "b4a5f7", Playermat = "bd0ff4", ResourceCounter = "816d84", + TokenDiscardZone = "457de4", Trash = "f7b6c8" }, Green = { @@ -30,6 +32,7 @@ local GuidReferences = { InvestigatorSkillTracker = "af7ed7", Playermat = "383d8b", ResourceCounter = "cd15ac", + TokenDiscardZone = "457de5", Trash = "5f896a" }, Red = { @@ -41,6 +44,7 @@ local GuidReferences = { InvestigatorSkillTracker = "e74881", Playermat = "0840d5", ResourceCounter = "a4b60d", + TokenDiscardZone = "457de6", Trash = "4b8594" }, Mythos = { diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 92e088bf..12b6364d 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -186,6 +186,28 @@ function tryObjectEnterContainer(container, object) return true end +-- TTS event for objects that enter zones +-- used to detect the "token discard zones" beneath the hand zones +function onObjectEnterZone(zone, enteringObj) + if tokenChecker.isChaosToken(enteringObj) then return end + + local match = false + for _, tokenDiscardZone in pairs(guidReferenceApi.getObjectsByType("TokenDiscardZone")) do + if zone == tokenDiscardZone then + match = true + break + end + end + + if match == false then return end + + if enteringObj.type == "Tile" and enteringObj.getMemo() and enteringObj.getLock() == false then + local matcolor = playmatApi.getMatColorByPosition(enteringObj.getPosition()) + local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, "Trash") + trash.putObject(enteringObj) + end +end + --------------------------------------------------------- -- chaos token drawing --------------------------------------------------------- diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 00274ff4..5465a9cf 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -89,9 +89,6 @@ local matColor = self.getMemo() -- variable to track the status of the "Show Draw Button" option local isDrawButtonVisible = false --- limit search calls if multiple cards enter the hand -local pendingHandSearch = false - -- global variable to report "Dream-Enhancing Serum" status isDES = false @@ -185,10 +182,6 @@ 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 -function isUnlockedTokenOrTileWithMemo(x) - return (x.type == "Token" or x.type == "Tile") and x.getMemo() and x.getLock() == false -end - -- finds all objects on the playmat and associated set aside zone. function searchAroundSelf(filter) local bounds = self.getBoundsNormalized() @@ -818,21 +811,6 @@ function resetSkillTracker() end end --- removal of tokens when a card enters the hand by searching the area below the handzone for tokens/tiles -function onObjectEnterZone(zone) - if pendingHandSearch == false and zone == ownedObjects.HandZone then - pendingHandSearch = true - Wait.time(function() - local searchPos = zone.getPosition():setAt("y", 1.5) - local searchSize = zone.getScale():setAt("y", 1) - for _, obj in ipairs(searchArea(searchPos, searchSize, isUnlockedTokenOrTileWithMemo)) do - ownedObjects.Trash.putObject(obj) - end - pendingHandSearch = false - end, 1) - end -end - --------------------------------------------------------- -- calls to 'Global' / functions for calls from outside --------------------------------------------------------- diff --git a/src/util/TokenRemover.ttslua b/src/util/TokenRemover.ttslua deleted file mode 100644 index 8e7bc84b..00000000 --- a/src/util/TokenRemover.ttslua +++ /dev/null @@ -1,52 +0,0 @@ -local zone = nil -local tokenChecker = require("core/token/TokenChecker") - --- general code -function onSave() - return JSON.encode(zone and zone.getGUID() or nil) -end - -function onLoad(savedData) - if savedData ~= "" and savedData ~= nil then - zone = getObjectFromGUID(JSON.decode(savedData)) - end - setMenu(zone == nil) -end - --- context menu functions -function enable() - local scale = self.getScale() - zone = spawnObject({ - type = "ScriptingTrigger", - position = self.getPosition() + Vector(0, 2.5 + 0.11, 0), - rotation = self.getRotation(), - scale = { scale.x * 2, 5, scale.z * 2 } - }) - setMenu(false) -end - -function disable() - if zone ~= nil then zone.destruct() end - setMenu(true) -end - --- core functions -function setMenu(isEnabled) - self.clearContextMenu() - if isEnabled then - self.addContextMenuItem("Enable", enable) - else - self.addContextMenuItem("Disable", disable) - end -end - -function onObjectEnterScriptingZone(entering, object) - if zone ~= entering then return end - if object == self or object.type == "Deck" or object.type == "Card" then return end - if tokenChecker.isChaosToken(object) then return end - object.destruct() -end - -function onPickUp() - disable() -end