local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } local playmatAPI = require("playermat/PlaymatApi") function onLoad() self.addContextMenuItem("Discard 10 cards", shortSupply) end -- called by context menu entry function shortSupply(color) local cardPos = self.getPosition() local mat = playmatAPI.getMatbyColor(getMatColor(cardPos)) 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 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