getCrankTicks, is it possible to not tick on 0? AKA how to get 1 full turn?

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

Thank you for your time and consideration,

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.

1 Like

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

1 Like