From 0b6eb32f750ee4d627ebce5e58201f56886dd9ad Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 03:29:16 +0100 Subject: [PATCH 1/9] moving short supply function directly to card --- .../ShortSupply.e5f541.json | 2 +- .../ShortSupply.e5f541.ttslua | 57 +++++++++ .../HandHelper.450688.ttslua | 110 ++++++------------ 3 files changed, 93 insertions(+), 76 deletions(-) create mode 100644 objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.json b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.json index 864d643d..74ebcdf6 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.json +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.json @@ -33,8 +33,8 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", "LuaScriptState": "", + "LuaScript_path": "AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua", "MeasureMovement": false, "Name": "Card", "Nickname": "Short Supply", diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua new file mode 100644 index 00000000..a563189b --- /dev/null +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -0,0 +1,57 @@ +local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } + +function onLoad() + self.addContextMenuItem("Discard 10 cards", shortSupply) +end + +-- called by context menu entry +function shortSupply(color) + local cardPos = self.getPosition() + local playerNumber = getPlayernumber(cardPos) + local mat = getObjectFromGUID(MAT_GUIDS[playerNumber]) + if mat == nil then return end + + -- get draw deck and discard pile + mat.call("getDrawDiscardDecks") + local drawDeck = mat.getVar("drawDeck") + local discardPos = mat.getTable("DISCARD_PILE_POSITION") + if discardPos == nil then + broadcastToAll("Couldn't retrieve discard position from playermat!", "Red") + return + end + + if drawDeck == nil then + broadcastToColor("Deck not found!", color, "Yellow") + return + elseif drawDeck.tag ~= "Deck" then + broadcastToColor("Deck only contains a single card!", color, "Yellow") + return + end + + -- discard cards + discardPos.y = 0.5 + for i = 1, 10 do + discardPos.y = discardPos.y + 0.05 * i + drawDeck.takeObject({ + flip = true, + position = discardPos + }) + end +end + +-- helper to find playernumber based on position +function getPlayernumber(cardPos) + if cardPos.x < -42 then + if cardPos.z > 0 then + return 1 + else + return 2 + end + else + if cardPos.z > 0 then + return 3 + else + return 4 + end + end +end diff --git a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua index c186124a..d32b3051 100644 --- a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua @@ -1,7 +1,7 @@ MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } -local BUTTON_PARAMETERS = {} -BUTTON_PARAMETERS.function_owner = self +local buttonParamaters = {} +buttonParamaters.function_owner = self -- saving "playerColor" and "des" function onSave() return JSON.encode({ playerColor, des}) end @@ -13,41 +13,41 @@ function onLoad(saved_data) des = loaded_data[2] or false -- index 0: button as hand size label - BUTTON_PARAMETERS.hover_color = "White" - BUTTON_PARAMETERS.click_function = "none" - BUTTON_PARAMETERS.position = { 0, 0.1, -0.4 } - BUTTON_PARAMETERS.height = 0 - BUTTON_PARAMETERS.width = 0 - BUTTON_PARAMETERS.font_size = 500 - BUTTON_PARAMETERS.font_color = "White" - self.createButton(BUTTON_PARAMETERS) + buttonParamaters.hover_color = "White" + buttonParamaters.click_function = "none" + buttonParamaters.position = { 0, 0.11, -0.4 } + buttonParamaters.height = 0 + buttonParamaters.width = 0 + buttonParamaters.font_size = 500 + buttonParamaters.font_color = "White" + self.createButton(buttonParamaters) -- index 1: button to toggle "des" - BUTTON_PARAMETERS.label = "DES: " .. (des and "✓" or "✗") - BUTTON_PARAMETERS.click_function = "toggleDES" - BUTTON_PARAMETERS.position = { 0.475, 0.1, 0.25 } - BUTTON_PARAMETERS.height = 175 - BUTTON_PARAMETERS.width = 440 - BUTTON_PARAMETERS.font_size = 90 - BUTTON_PARAMETERS.font_color = "Black" - self.createButton(BUTTON_PARAMETERS) + buttonParamaters.label = "DES: " .. (des and "✓" or "✗") + buttonParamaters.click_function = "toggleDES" + buttonParamaters.position = { 0.475, 0.11, 0.25 } + buttonParamaters.height = 175 + buttonParamaters.width = 440 + buttonParamaters.font_size = 90 + buttonParamaters.font_color = "Black" + self.createButton(buttonParamaters) -- index 2: button to discard a card - BUTTON_PARAMETERS.label = "discard random card" - BUTTON_PARAMETERS.click_function = "discardRandom" - BUTTON_PARAMETERS.position = { 0, 0.1, 0.7 } - BUTTON_PARAMETERS.width = 900 - self.createButton(BUTTON_PARAMETERS) + buttonParamaters.label = "discard random card" + buttonParamaters.click_function = "discardRandom" + buttonParamaters.position = { 0, 0.11, 0.7 } + buttonParamaters.width = 900 + self.createButton(buttonParamaters) -- index 3: button to select color - BUTTON_PARAMETERS.label = playerColor - BUTTON_PARAMETERS.color = playerColor - BUTTON_PARAMETERS.hover_color = playerColor - BUTTON_PARAMETERS.click_function = "changeColor" - BUTTON_PARAMETERS.tooltip = "change color" - BUTTON_PARAMETERS.position = { -0.475, 0.1, 0.25 } - BUTTON_PARAMETERS.width = 440 - self.createButton(BUTTON_PARAMETERS) + buttonParamaters.label = playerColor + buttonParamaters.color = playerColor + buttonParamaters.hover_color = playerColor + buttonParamaters.click_function = "changeColor" + buttonParamaters.tooltip = "change color" + buttonParamaters.position = { -0.475, 0.11, 0.25 } + buttonParamaters.width = 440 + self.createButton(buttonParamaters) -- start loop to update card count loopId = Wait.time(||updateValue(), 1, -1) @@ -71,14 +71,6 @@ function onLoad(saved_data) end function onObjectHover(hover_color, obj) - -- error handling - if obj == nil then return end - - -- add context menu to "short supply" - if obj.getName() == "Short Supply" then - obj.addContextMenuItem("Discard 10 (" .. playerColor .. ")", shortSupply) - end - -- only continue if correct player hovers over "self" if obj ~= self or hover_color ~= playerColor then return end @@ -151,11 +143,11 @@ function changeColor(_, _, isRightClick, color) end -- update "change color" button (note: remove and create instantly updates hover_color) - BUTTON_PARAMETERS.label = playerColor - BUTTON_PARAMETERS.color = playerColor - BUTTON_PARAMETERS.hover_color = playerColor + buttonParamaters.label = playerColor + buttonParamaters.color = playerColor + buttonParamaters.hover_color = playerColor self.removeButton(3) - self.createButton(BUTTON_PARAMETERS) + self.createButton(buttonParamaters) end --------------------------------------------------------- @@ -184,38 +176,6 @@ function discardRandom() end end ---------------------------------------------------------- --- discards the top 10 cards of your deck ---------------------------------------------------------- -function shortSupply(color) - local mat = getPlayermat(playerColor) - if mat == nil then return end - - -- get draw deck and discard pile - mat.call("getDrawDiscardDecks") - drawDeck = mat.getVar("drawDeck") - local discardPos = mat.getTable("DISCARD_PILE_POSITION") - if discardPos == nil then - broadcastToAll("Couldn't retrieve discard position from playermat!", "Red") - return - end - - if drawDeck == nil then - broadcastToColor("Deck not found!", color, "Yellow") - return - elseif drawDeck.tag ~= "Deck" then - broadcastToColor("Deck only contains a single card!", color, "Yellow") - return - end - - -- discard cards - discardPos[2] = 0.5 - for i = 1, 10 do - discardPos[2] = discardPos[2] + 0.05 * i - drawDeck.takeObject({ flip = true; position = discardPos }) - end -end - --------------------------------------------------------- -- helper functions --------------------------------------------------------- From bdccbf707be08225b3fcff3b4644e5a2a71ba532 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 13:35:59 +0100 Subject: [PATCH 2/9] implemented usage of playmatapi --- .../ShortSupply.e5f541.ttslua | 19 +++++++++++-------- src/playermat/PlaymatApi.ttslua | 6 ++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index a563189b..17b6cb0a 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -1,5 +1,7 @@ local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } +local playmatAPI = require("playermat/PlaymatApi") + function onLoad() self.addContextMenuItem("Discard 10 cards", shortSupply) end @@ -7,8 +9,7 @@ end -- called by context menu entry function shortSupply(color) local cardPos = self.getPosition() - local playerNumber = getPlayernumber(cardPos) - local mat = getObjectFromGUID(MAT_GUIDS[playerNumber]) + local mat = playmatAPI.getMatbyColor(getMatColor(cardPos)) if mat == nil then return end -- get draw deck and discard pile @@ -39,19 +40,21 @@ function shortSupply(color) end end --- helper to find playernumber based on position -function getPlayernumber(cardPos) +-- helper to find playermat color based on position +function getMatColor(cardPos) + local color if cardPos.x < -42 then if cardPos.z > 0 then - return 1 + color = "White" else - return 2 + color = "Orange" end else if cardPos.z > 0 then - return 3 + color = "Green" else - return 4 + color = "Red" end end + return color end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index ba6f1687..7721dff0 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -23,6 +23,12 @@ do Red = "4111de" } + -- Returns the by color requested playermat as object + ---@param matColor String Color of the playermat to return + PlaymatApi.getMatbyColor = function(matColor) + return getObjectFromGUID(MAT_IDS[matColor]) + 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 From ee6925bf0dcc33f8e7219171fbd358739cae3c9a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 13:37:41 +0100 Subject: [PATCH 3/9] removed unused lines --- objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua | 2 -- 1 file changed, 2 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index 17b6cb0a..41a2accc 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -1,5 +1,3 @@ -local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } - local playmatAPI = require("playermat/PlaymatApi") function onLoad() From a55d1dff58aab8f027ebd76bb07015d90959131a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 13:45:47 +0100 Subject: [PATCH 4/9] new function for playermat api --- .../ShortSupply.e5f541.ttslua | 21 +----------- .../HandHelper.450688.ttslua | 29 ++--------------- src/playermat/PlaymatApi.ttslua | 32 ++++++++++++++++++- 3 files changed, 35 insertions(+), 47 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index 41a2accc..e8da6501 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -7,7 +7,7 @@ end -- called by context menu entry function shortSupply(color) local cardPos = self.getPosition() - local mat = playmatAPI.getMatbyColor(getMatColor(cardPos)) + local mat = playmatAPI.getMatbyPosition(cardPos) if mat == nil then return end -- get draw deck and discard pile @@ -37,22 +37,3 @@ function shortSupply(color) }) end end - --- helper to find playermat color based on position -function getMatColor(cardPos) - local color - if cardPos.x < -42 then - if cardPos.z > 0 then - color = "White" - else - color = "Orange" - end - else - if cardPos.z > 0 then - color = "Green" - else - color = "Red" - end - end - return color -end diff --git a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua index d32b3051..3204c68f 100644 --- a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.ttslua @@ -1,4 +1,4 @@ -MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } +local playmatAPI = require("playermat/PlaymatApi") local buttonParamaters = {} buttonParamaters.function_owner = self @@ -161,7 +161,8 @@ function discardRandom() if #hand == 0 then broadcastToAll("Cannot discard from empty hand!", "Red") else - local mat = getPlayermat(playerColor) + local searchPos = Player[playerColor].getHandTransform().position + local mat = playmatAPI.getMatbyPosition(searchPos) if mat == nil then return end local discardPos = mat.getTable("DISCARD_PILE_POSITION") @@ -192,27 +193,3 @@ function playerExists(color) local COLORS = Player.getAvailableColors() return indexOf(COLORS, color) and true or false end - --- helper to find playermat based on hand position -function getPlayermat(color) - local pos = Player[playerColor].getHandTransform().position - if pos.x < -30 then - if pos.z > 0 then - playerNumber = 1 - else - playerNumber = 2 - end - else - if pos.z > 0 then - playerNumber = 3 - else - playerNumber = 4 - end - end - - local mat = getObjectFromGUID(MAT_GUIDS[playerNumber]) - if mat == nil then - broadcastToAll(playerColor .. " playermat could not be found!", "Yellow") - end - return mat -end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 7721dff0..73071295 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -26,7 +26,37 @@ do -- Returns the by color requested playermat as object ---@param matColor String Color of the playermat to return PlaymatApi.getMatbyColor = function(matColor) - return getObjectFromGUID(MAT_IDS[matColor]) + local mat = getObjectFromGUID(MAT_IDS[matColor]) + + if mat == nil then + broadcastToAll(playerColor .. " playermat could not be found!", "Yellow") + end + return mat + end + + -- Returns the by position requested playermat as object + ---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat + PlaymatApi.getMatbyPosition = function(startPos) + local matColor + if startPos.x < -42 then + if startPos.z > 0 then + matColor = "White" + else + matColor = "Orange" + end + else + if startPos.z > 0 then + matColor = "Green" + else + matColor = "Red" + end + end + local mat = getObjectFromGUID(MAT_IDS[matColor]) + + if mat == nil then + broadcastToAll(playerColor .. " playermat could not be found!", "Yellow") + end + return mat end -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If From d97453207230c21362cd6517cae5e0f5120531be Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 22 Dec 2022 14:32:43 +0100 Subject: [PATCH 5/9] adding missing tags --- .../Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.json | 1 + objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.json | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.json b/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.json index c3fddf97..c8011877 100644 --- a/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.json +++ b/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.json @@ -41,6 +41,7 @@ "Snap": true, "Sticky": true, "Tags": [ + "CleanUpHelper_ignore", "displacement_excluded" ], "Tooltip": true, diff --git a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.json b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.json index 9e917d47..c1137ca5 100644 --- a/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.json +++ b/objects/Fan-MadeAccessories.aa8b38/HandHelper.450688.json @@ -40,6 +40,10 @@ "Nickname": "Hand Helper", "Snap": true, "Sticky": true, + "Tags": [ + "CleanUpHelper_ignore", + "displacement_excluded" + ], "Tooltip": true, "Transform": { "posX": 37.613, From f464e5f0ff6ee8fd4ed51add686f7747106aee24 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 30 Dec 2022 20:25:50 +0100 Subject: [PATCH 6/9] implementing further usage of playmatAPI --- .../ShortSupply.e5f541.ttslua | 18 +++---- src/playermat/PlaymatApi.ttslua | 51 +++++++++++-------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index e8da6501..6110f0de 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -6,14 +6,13 @@ end -- called by context menu entry function shortSupply(color) - local cardPos = self.getPosition() - local mat = playmatAPI.getMatbyPosition(cardPos) - if mat == nil then return end + local matColor = playmatAPI.getMatColorbyPosition(self.getPosition()) - -- get draw deck and discard pile - mat.call("getDrawDiscardDecks") - local drawDeck = mat.getVar("drawDeck") - local discardPos = mat.getTable("DISCARD_PILE_POSITION") + -- get draw deck and discard position + local drawDeck = playmatAPI.getDrawDeck(matColor) + local discardPos = playmatAPI.getDiscardPosition(matColor) + + -- error handling if discardPos == nil then broadcastToAll("Couldn't retrieve discard position from playermat!", "Red") return @@ -31,9 +30,6 @@ function shortSupply(color) discardPos.y = 0.5 for i = 1, 10 do discardPos.y = discardPos.y + 0.05 * i - drawDeck.takeObject({ - flip = true, - position = discardPos - }) + drawDeck.takeObject({ flip = true, position = discardPos }) end end diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 73071295..b3b6af92 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -3,24 +3,24 @@ do local internal = { } local MAT_IDS = { - White = "8b081b", + White = "8b081b", Orange = "bd0ff4", - Green = "383d8b", - Red = "0840d5" + Green = "383d8b", + Red = "0840d5" } local CLUE_COUNTER_GUIDS = { - White = "37be78", + White = "37be78", Orange = "1769ed", - Green = "032300", - Red = "d86b7c" + Green = "032300", + Red = "d86b7c" } local CLUE_CLICKER_GUIDS = { - White = "db85d6", + White = "db85d6", Orange = "3f22e5", - Green = "891403", - Red = "4111de" + Green = "891403", + Red = "4111de" } -- Returns the by color requested playermat as object @@ -34,29 +34,36 @@ do return mat end - -- Returns the by position requested playermat as object + -- Returns the color of the by position requested playermat as string ---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat - PlaymatApi.getMatbyPosition = function(startPos) - local matColor + PlaymatApi.getMatColorbyPosition = function(startPos) if startPos.x < -42 then if startPos.z > 0 then - matColor = "White" + return "White" else - matColor = "Orange" + return "Orange" end else if startPos.z > 0 then - matColor = "Green" + return "Green" else - matColor = "Red" + return "Red" end - end - local mat = getObjectFromGUID(MAT_IDS[matColor]) + end - if mat == nil then - broadcastToAll(playerColor .. " playermat could not be found!", "Yellow") - end - return mat + -- Returns the draw deck of the requested playmat + ---@param matColor String Color of the playermat + PlaymatApi.getDrawDeck = function(matColor) + local mat = getObjectFromGUID(MAT_IDS[matColor]) + mat.call("getDrawDiscardDecks") + return mat.getVar("drawDeck") + end + + -- Returns the position of the discard pile of the requested playmat + ---@param matColor String Color of the playermat + PlaymatApi.getDiscardPosition = function(matColor) + local mat = getObjectFromGUID(MAT_IDS[matColor]) + return mat.getTable("DISCARD_PILE_POSITION") end -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If From 08936a7230a5172e030e3b8144e4a79904b62787 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 30 Dec 2022 20:43:55 +0100 Subject: [PATCH 7/9] bugfix and feedback --- objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua | 1 + src/playermat/PlaymatApi.ttslua | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index 6110f0de..115b4792 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -27,6 +27,7 @@ function shortSupply(color) end -- discard cards + broadcastToColor("Discarding top 10 cards for player color '" .. matColor .. "'.", color, "White") discardPos.y = 0.5 for i = 1, 10 do discardPos.y = discardPos.y + 0.05 * i diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index b3b6af92..25aaaea2 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -49,6 +49,7 @@ do else return "Red" end + end end -- Returns the draw deck of the requested playmat @@ -122,7 +123,7 @@ do -- Convenience function to look up a mat's object by color, or get all mats. ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will return all four mats. - ---@return Array of playermat objects. If a single mat is requested, will return a single-element + ---@return: Array of playermat objects. If a single mat is requested, will return a single-element -- array to simplify processing by consumers. internal.getMatForColor = function(matColor) local targetMatGuid = MAT_IDS[matColor] From f5ac476e35e4a1ddd7f7aaa1fd598126a1d8e349 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 31 Dec 2022 00:14:02 +0100 Subject: [PATCH 8/9] changing broadcast color --- objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index 115b4792..71ce480b 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -14,7 +14,7 @@ function shortSupply(color) -- error handling if discardPos == nil then - broadcastToAll("Couldn't retrieve discard position from playermat!", "Red") + broadcastToColor("Couldn't retrieve discard position from playermat!", color, "Red") return end From 3c240dcdc8f514add45505072aa8212bf1b444a0 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Sat, 31 Dec 2022 02:57:50 +0100 Subject: [PATCH 9/9] removing unused function --- .../AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua | 2 +- src/playermat/PlaymatApi.ttslua | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua index 71ce480b..548ea019 100644 --- a/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua +++ b/objects/AllPlayerCards.15bb07/ShortSupply.e5f541.ttslua @@ -6,7 +6,7 @@ end -- called by context menu entry function shortSupply(color) - local matColor = playmatAPI.getMatColorbyPosition(self.getPosition()) + local matColor = playmatAPI.getMatColorByPosition(self.getPosition()) -- get draw deck and discard position local drawDeck = playmatAPI.getDrawDeck(matColor) diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 25aaaea2..621c22de 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -23,20 +23,9 @@ do Red = "4111de" } - -- Returns the by color requested playermat as object - ---@param matColor String Color of the playermat to return - PlaymatApi.getMatbyColor = function(matColor) - local mat = getObjectFromGUID(MAT_IDS[matColor]) - - if mat == nil then - broadcastToAll(playerColor .. " playermat could not be found!", "Yellow") - end - return mat - end - -- Returns the color of the by position requested playermat as string ---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat - PlaymatApi.getMatColorbyPosition = function(startPos) + PlaymatApi.getMatColorByPosition = function(startPos) if startPos.x < -42 then if startPos.z > 0 then return "White"