From 2343cd8eb0a0a7e4424c7fe1cef0fda5061b2d6d Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 9 Mar 2023 23:55:40 +0100 Subject: [PATCH 1/3] updated positions --- src/core/Global.ttslua | 16 ++++++++-------- src/playermat/Playmat.ttslua | 4 ++++ src/playermat/PlaymatApi.ttslua | 10 +++++++++- src/playermat/Zones.ttslua | 6 +++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index e3e7afbf..cbca475f 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -850,17 +850,17 @@ function applyOptionPanelChange(id, state) -- option: Show hand helper for each player elseif id == "showHandHelper" then - optionPanel[id][1] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, 7.32}, {0, 270, 0}) - optionPanel[id][2] = spawnOrRemoveHelper(state, "Hand Helper", {-50.85, 1.6, -24.88}, {0, 270, 0}) - optionPanel[id][3] = spawnOrRemoveHelper(state, "Hand Helper", {-39.13, 1.6, 22.45}, {0, 000, 0}) - optionPanel[id][4] = spawnOrRemoveHelper(state, "Hand Helper", {-21.57, 1.6, -22.45}, {0, 180, 0}) + optionPanel[id][1] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "White") , {0, 270, 0}) + optionPanel[id][2] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Orange"), {0, 270, 0}) + optionPanel[id][3] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Green"), {0, 000, 0}) + optionPanel[id][4] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Red"), {0, 180, 0}) -- option: Show search assistant for each player elseif id == "showSearchAssistant" then - optionPanel[id][1] = spawnOrRemoveHelper(state, "Search Assistant", {-50.85, 1.6, 10.25}, {0, 270, 0}) - optionPanel[id][2] = spawnOrRemoveHelper(state, "Search Assistant", {-50.85, 1.6, -21.95}, {0, 270, 0}) - optionPanel[id][3] = spawnOrRemoveHelper(state, "Search Assistant", {-36.20, 1.6, 22.45}, {0, 000, 0}) - optionPanel[id][4] = spawnOrRemoveHelper(state, "Search Assistant", {-24.50, 1.6, -22.45}, {0, 180, 0}) + optionPanel[id][1] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "White"), {0, 270, 0}) + optionPanel[id][2] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Orange"), {0, 270, 0}) + optionPanel[id][3] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Green"), {0, 000, 0}) + optionPanel[id][4] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Red"), {0, 180, 0}) -- option: Show chaos bag manager elseif id == "showChaosBagManager" then diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 0893bf38..d1250715 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -700,6 +700,10 @@ function returnGlobalDiscardPosition() return self.positionToWorld(DISCARD_PILE_POSITION) end +function transformLocalPosition(localPos) + return self.positionToWorld(localPos) +end + -- Sets this playermat's draw 1 button to visible ---@param visible Boolean. Whether the draw 1 button should be visible function showDrawButton(visible) diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index a04893fc..d9f11010 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -48,7 +48,7 @@ do return mat.call("getHandColor") end - -- Returns if there is the card"Dream-Enhancing Serum" on the requested playermat + -- 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]) @@ -70,6 +70,14 @@ do return mat.call("returnGlobalDiscardPosition") end + -- Transforms a local position into a global position + ---@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]) + return mat.call("transformLocalPosition", localPos) + end + -- Sets the requested 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 diff --git a/src/playermat/Zones.ttslua b/src/playermat/Zones.ttslua index 96ab1bce..6efb17aa 100644 --- a/src/playermat/Zones.ttslua +++ b/src/playermat/Zones.ttslua @@ -28,9 +28,9 @@ do playerMatGuids["White"] = "8b081b" playerMatGuids["Green"] = "383d8b" - local commonZones = {} + local commonZones = {} commonZones["Investigator"] = { -1.17702, 0, 0.00209 } - commonZones["Minicard"] = { -0.16, 0, -1.222326 } + commonZones["Minicard"] = { -1.17702, 0, -1.45 } commonZones["Deck"] = { -1.822724, 0, -0.02940192 } commonZones["Discard"] = { -1.822451, 0, 0.6092291 } commonZones["Ally"] = { -0.6157398, 0, 0.02435675 } @@ -48,7 +48,7 @@ do commonZones["Threat3"] = { 0.002246313, 0, -0.6430681 } commonZones["Threat4"] = { 0.4590618, 0, -0.6432732 } - local zoneData = {} + local zoneData = {} zoneData["White"] = {} zoneData["White"]["Investigator"] = commonZones["Investigator"] zoneData["White"]["Minicard"] = commonZones["Minicard"] From 62b3c29bda0d7b4b0b2f4c49cd11309e0e2bb9b9 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 10 Mar 2023 00:19:01 +0100 Subject: [PATCH 2/3] making rotation relative --- src/core/Global.ttslua | 20 +++++++++++--------- src/playermat/Playmat.ttslua | 15 +++++---------- src/playermat/PlaymatApi.ttslua | 9 ++++++++- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index cbca475f..08234c7c 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -29,6 +29,7 @@ local chaosTokens = {} local chaosTokensLastMat = nil local IS_RESHUFFLING = false local bagSearchers = {} +local MAT_COLORS = {"White", "Orange", "Green", "Red"} local hideTitleSplashWaitFunctionId = nil local playmatAPI = require("playermat/PlaymatApi") local tokenManager = require("core/token/TokenManager") @@ -850,17 +851,19 @@ function applyOptionPanelChange(id, state) -- option: Show hand helper for each player elseif id == "showHandHelper" then - optionPanel[id][1] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "White") , {0, 270, 0}) - optionPanel[id][2] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Orange"), {0, 270, 0}) - optionPanel[id][3] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Green"), {0, 000, 0}) - optionPanel[id][4] = spawnOrRemoveHelper(state, "Hand Helper", playmatAPI.transformLocalPosition({0.05, 0, -1.182}, "Red"), {0, 180, 0}) + 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) + end -- option: Show search assistant for each player elseif id == "showSearchAssistant" then - optionPanel[id][1] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "White"), {0, 270, 0}) - optionPanel[id][2] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Orange"), {0, 270, 0}) - optionPanel[id][3] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Green"), {0, 000, 0}) - optionPanel[id][4] = spawnOrRemoveHelper(state, "Search Assistant", playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, "Red"), {0, 180, 0}) + 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) + end -- option: Show chaos bag manager elseif id == "showChaosBagManager" then @@ -907,7 +910,6 @@ end ---@param name String Name of the object that should be copied ---@param position Table Desired position of the object function spawnHelperObject(name, position, rotation) - local sourceBag = getObjectFromGUID("830bd0") -- error handling for missing sourceBag diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index d1250715..fbc72e82 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -52,7 +52,6 @@ local THREAT_AREA = { local DRAW_DECK_POSITION = { x = -1.82, y = 1, z = 0 } local DISCARD_PILE_POSITION = { x = -1.82, y = 1.5, z = 0.61 } -local PLAY_ZONE_ROTATION = self.getRotation() local TRASHCAN local STAT_TRACKER @@ -158,7 +157,7 @@ function searchArea(origin, size) return Physics.cast({ origin = origin, direction = {0, 1, 0}, - orientation = PLAY_ZONE_ROTATION, + orientation = self.getRotation(), type = 3, size = size, max_distance = 1, @@ -181,7 +180,7 @@ function makeDiscardHandlerFor(searchPosition, discardPosition) if obj.tag == "Deck" or obj.tag == "Card" then if obj.hasTag("PlayerCard") then obj.setPositionSmooth(self.positionToWorld(DISCARD_PILE_POSITION), false, true) - obj.setRotation(PLAY_ZONE_ROTATION) + obj.setRotation(self.getRotation()) else obj.setPositionSmooth(discardPosition, false, true) obj.setRotation({0, -90, 0}) @@ -220,7 +219,7 @@ function findObjectsAtPosition(localPos) return Physics.cast({ origin = self.positionToWorld(localPos), direction = {0, 1, 0}, - orientation = {0, PLAY_ZONE_ROTATION.y + 90, 0}, + orientation = {0, self.getRotation().y + 90, 0}, type = 3, size = {3.2, 1, 2}, max_distance = 0, @@ -252,7 +251,7 @@ function doUpkeep(_, color, alt_click) elseif obj.tag == "Card" and not obj.is_face_down and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then local cardMetadata = JSON.decode(obj.getGMNotes()) or {} if not doNotReady(obj) then - obj.setRotation(PLAY_ZONE_ROTATION) + obj.setRotation(self.getRotation()) end if cardMetadata.id == "08031" then forcedLearning = true @@ -700,10 +699,6 @@ function returnGlobalDiscardPosition() return self.positionToWorld(DISCARD_PILE_POSITION) end -function transformLocalPosition(localPos) - return self.positionToWorld(localPos) -end - -- Sets this playermat's draw 1 button to visible ---@param visible Boolean. Whether the draw 1 button should be visible function showDrawButton(visible) @@ -766,7 +761,7 @@ function clickableClues(showCounter) local pos = self.positionToWorld({x = -1.12, y = 0.05, z = 0.7}) for i = 1, clueCount do pos.y = pos.y + 0.045 * i - tokenManager.spawnToken(pos, "clue", PLAY_ZONE_ROTATION) + tokenManager.spawnToken(pos, "clue", self.getRotation()) end end end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index d9f11010..df49ded4 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -75,7 +75,14 @@ do ---@param matColor String Color of the playermat PlaymatApi.transformLocalPosition = function(localPos, matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) - return mat.call("transformLocalPosition", localPos) + 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]) + return mat.getRotation() end -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If From eda30c74380f4329a3d52de04357aa1c7d0d1f6f Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 10 Mar 2023 12:47:42 +0100 Subject: [PATCH 3/3] changing "playmatAPI" to "playmatApi" --- src/core/Global.ttslua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 08234c7c..bdf34087 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -31,7 +31,7 @@ local IS_RESHUFFLING = false local bagSearchers = {} local MAT_COLORS = {"White", "Orange", "Green", "Red"} local hideTitleSplashWaitFunctionId = nil -local playmatAPI = require("playermat/PlaymatApi") +local playmatApi = require("playermat/PlaymatApi") local tokenManager = require("core/token/TokenManager") local playAreaAPI = require("core/PlayAreaApi") @@ -812,17 +812,17 @@ end function applyOptionPanelChange(id, state) -- option: Snap tags if id == "useSnapTags" then - playmatAPI.setLimitSnapsByType(state, "All") + playmatApi.setLimitSnapsByType(state, "All") optionPanel[id] = state -- option: Draw 1 button elseif id == "showDrawButton" then - playmatAPI.showDrawButton(state, "All") + playmatApi.showDrawButton(state, "All") optionPanel[id] = state -- option: Clickable clue counters elseif id == "useClueClickers" then - playmatAPI.clickableClues(state, "All") + playmatApi.clickableClues(state, "All") optionPanel[id] = state -- update master clue counter @@ -852,16 +852,16 @@ function applyOptionPanelChange(id, state) -- option: Show hand helper for each player elseif id == "showHandHelper" then for i, color in ipairs(MAT_COLORS) do - local pos = playmatAPI.transformLocalPosition({0.05, 0, -1.182}, color) - local rot = playmatAPI.returnRotation(color) + local pos = playmatApi.transformLocalPosition({0.05, 0, -1.182}, color) + local rot = playmatApi.returnRotation(color) optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot) end -- option: Show search assistant for each player elseif id == "showSearchAssistant" then for i, color in ipairs(MAT_COLORS) do - local pos = playmatAPI.transformLocalPosition({-0.3, 0, -1.182}, color) - local rot = playmatAPI.returnRotation(color) + local pos = playmatApi.transformLocalPosition({-0.3, 0, -1.182}, color) + local rot = playmatApi.returnRotation(color) optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot) end