I am trying to have my actions process after the crank turns one full revolution. Ideally 1 full revolution from it's current position, but I'll take what I can get at this point.
From what I have read in other posts, 0 degrees counts as your first tick, no matter what you put for you variable. Has anyone dev'd a way around this?
local function handleCrankTurn()
if pd.getCrankTicks(1) >= 1 then
local indices = {}
for i in pairs(referenceDeck) do
table.insert(indices, i)
end
shuffledDeck = shuffle(indices)
deckStatus = "Shuffled"
updateCardActionSprite()
end
end
maybe you can use playdate.getCrankChange() instead and keep track of the changes until they add up to 360. This should also help with the "1 revolution from its initial position" requirement.
just gotta find a way to reset that accumulator variable when the crank hasnt moved in a while maybe.
It took AI helping me as a newbie to properly implement this, but I finally got it implemented and working as I wanted.
There's context cut out, but the core of the check is this which I call in my update() and I have it wrapped in a variable check a layer up.
local change, _ = pd.getCrankChange()
totalCrankMovement = totalCrankMovement + math.abs(change)
if totalCrankMovement >= 360 then
actionCall()
totalCrankMovement = 0
end