diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 27d5f525..c9731451 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -653,8 +653,7 @@ end -- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all -- cards. -- @param matchTypes Boolean. Whether snap points should only snap for the matching card types. -function setLimitSnapsByType(params) - local matchTypes = params.matchTypes +function setLimitSnapsByType(matchTypes) local snaps = self.getSnapPoints() for i, snap in ipairs(snaps) do local snapPos = snap.position @@ -691,7 +690,7 @@ end -- @param bounds Table. Defined area to see if the point is within. See MAIN_PLAY_AREA for sample -- bounds definition. -- @return Boolean. True if the point is in the area defined by bounds -local function inArea(point, bounds) +function inArea(point, bounds) return (point.x < bounds.upperLeft.x and point.x > bounds.lowerRight.x and point.z < bounds.upperLeft.z diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index d3421ffb..489387e4 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -2,10 +2,12 @@ do local PlaymatApi = { } local internal = { } - local WHITE_MAT_GUID = "8b081b" - local ORANGE_MAT_GUID = "bd0ff4" - local GREEN_MAT_GUID = "383d8b" - local RED_MAT_GUID = "0840d5" + local MAT_IDS = { + White = "8b081b", + Orange = "bd0ff4", + Green = "383d8b", + Red = "0840d5", + } -- 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 @@ -17,7 +19,7 @@ do -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do - mat.call("setLimitSnapsByType", { matchTypes = matchCardTypes }) + mat.call("setLimitSnapsByType", matchCardTypes) end end @@ -27,20 +29,16 @@ do -- @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) - if matColor == "White" then - return { getObjectFromGUID(WHITE_MAT_GUID) } - elseif matColor == "Orange" then - return { getObjectFromGUID(ORANGE_MAT_GUID) } - elseif matColor == "Green" then - return { getObjectFromGUID(GREEN_MAT_GUID) } - elseif matColor == "Red" then - return { getObjectFromGUID(RED_MAT_GUID) } - elseif matColor == "All" then + local targetMatGuid = MAT_IDS[matColor] + if targetMatGuid != nil then + return { getObjectFromGUID(targetMatGuid) } + end + if matColor == "All" then return { - getObjectFromGUID(WHITE_MAT_GUID), - getObjectFromGUID(ORANGE_MAT_GUID), - getObjectFromGUID(GREEN_MAT_GUID), - getObjectFromGUID(RED_MAT_GUID), + getObjectFromGUID(MAT_IDS.White), + getObjectFromGUID(MAT_IDS.Orange), + getObjectFromGUID(MAT_IDS.Green), + getObjectFromGUID(MAT_IDS.Red), } end end