added context menu function to tekelili cards to place below deck
This commit is contained in:
parent
34b820e97e
commit
e97b07d137
@ -122,6 +122,7 @@ function cleanUp(_, color)
|
|||||||
discardHands()
|
discardHands()
|
||||||
chaosBagApi.returnChaosTokens()
|
chaosBagApi.returnChaosTokens()
|
||||||
chaosBagApi.releaseAllSealedTokens(color)
|
chaosBagApi.releaseAllSealedTokens(color)
|
||||||
|
maybeIgnoreTekeliliCards()
|
||||||
|
|
||||||
printToAll("Tidying main play area...", "White")
|
printToAll("Tidying main play area...", "White")
|
||||||
startLuaCoroutine(self, "tidyPlayareaCoroutine")
|
startLuaCoroutine(self, "tidyPlayareaCoroutine")
|
||||||
@ -238,6 +239,18 @@ function discardHands()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- maybe ignore cards / decks on the tekelili helper
|
||||||
|
function maybeIgnoreTekeliliCards()
|
||||||
|
local tekeliliHelper = getTekeliliHelper()
|
||||||
|
|
||||||
|
if tekeliliHelper then
|
||||||
|
local searchResult = searchLib.onObject(tekeliliHelper, "isCardOrDeck")
|
||||||
|
for _, obj in ipairs(searchResult) do
|
||||||
|
obj.addTag(IGNORE_TAG)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- clean up for play area
|
-- clean up for play area
|
||||||
function tidyPlayareaCoroutine()
|
function tidyPlayareaCoroutine()
|
||||||
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
||||||
@ -271,14 +284,6 @@ end
|
|||||||
function tidyPlayerMatCoroutine()
|
function tidyPlayerMatCoroutine()
|
||||||
local tekeliliHelper = getTekeliliHelper()
|
local tekeliliHelper = getTekeliliHelper()
|
||||||
|
|
||||||
-- maybe ignore cards / decks on the tekelili helper
|
|
||||||
if tekeliliHelper then
|
|
||||||
local searchResult = searchLib.onObject(tekeliliHelper, "isCardOrDeck")
|
|
||||||
for _, obj in ipairs(searchResult) do
|
|
||||||
obj.addTag(IGNORE_TAG)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
-- only continue for playermat (1-4) if option enabled
|
-- only continue for playermat (1-4) if option enabled
|
||||||
if options["tidyPlayermats"] or i == 5 then
|
if options["tidyPlayermats"] or i == 5 then
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
|
local deckLib = require("util/DeckLib")
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
self.addContextMenuItem("Return this card", returnSelf)
|
self.addContextMenuItem("Return this card", returnSelf)
|
||||||
|
self.addContextMenuItem("Place below my deck", placeBelowDeck)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- uses the tekeli-li helper to place this card at the bottom of the deck
|
-- uses the tekeli-li helper to place this card at the bottom of the deck
|
||||||
@ -12,6 +16,15 @@ function returnSelf()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- places this card below the deck of the player that triggered it
|
||||||
|
function placeBelowDeck(playerColor)
|
||||||
|
local matColor = playmatApi.getMatColor(playerColor)
|
||||||
|
local deckPos = playmatApi.getDrawPosition(matColor)
|
||||||
|
local deckRot = playmatApi.returnRotation(matColor)
|
||||||
|
deckRot = deckRot:setAt("z", 180)
|
||||||
|
deckLib.placeOrMergeIntoDeck(self, Vector(deckPos), deckRot, true)
|
||||||
|
end
|
||||||
|
|
||||||
-- used to detect the "Tekeli-li Helper" for Edge of the Earth
|
-- used to detect the "Tekeli-li Helper" for Edge of the Earth
|
||||||
function getTekeliliHelper()
|
function getTekeliliHelper()
|
||||||
for _, obj in ipairs(getObjects()) do
|
for _, obj in ipairs(getObjects()) do
|
||||||
|
@ -5,21 +5,25 @@ do
|
|||||||
-- places a card/deck at a position or merges into an existing deck
|
-- places a card/deck at a position or merges into an existing deck
|
||||||
---@param obj tts__Object Object to move
|
---@param obj tts__Object Object to move
|
||||||
---@param pos table New position for the object
|
---@param pos table New position for the object
|
||||||
---@param rot table New rotation for the object (optional)
|
---@param rot? table New rotation for the object
|
||||||
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot)
|
---@param below? boolean Should the object be placed below an existing deck?
|
||||||
|
DeckLib.placeOrMergeIntoDeck = function(obj, pos, rot, below)
|
||||||
if obj == nil or pos == nil then return end
|
if obj == nil or pos == nil then return end
|
||||||
|
|
||||||
-- search the new position for existing card/deck
|
-- search the new position for existing card/deck
|
||||||
local searchResult = searchLib.atPosition(pos, "isCardOrDeck")
|
local searchResult = searchLib.atPosition(pos, "isCardOrDeck")
|
||||||
|
|
||||||
-- get new position
|
-- get new position
|
||||||
local newPos
|
|
||||||
local offset = 0.5
|
local offset = 0.5
|
||||||
|
local newPos = Vector(pos) + Vector(0, offset, 0)
|
||||||
|
|
||||||
if #searchResult == 1 then
|
if #searchResult == 1 then
|
||||||
local bounds = searchResult[1].getBounds()
|
local bounds = searchResult[1].getBounds()
|
||||||
newPos = Vector(pos):setAt("y", bounds.center.y + bounds.size.y / 2 + offset)
|
if below then
|
||||||
|
newPos = Vector(pos):setAt("y", bounds.center.y - bounds.size.y / 2)
|
||||||
else
|
else
|
||||||
newPos = Vector(pos) + Vector(0, offset, 0)
|
newPos = Vector(pos):setAt("y", bounds.center.y + bounds.size.y / 2 + offset)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- allow moving the objects smoothly out of the hand
|
-- allow moving the objects smoothly out of the hand
|
||||||
|
Loading…
Reference in New Issue
Block a user