So using on crank do how do I then check how much crank has been used? Is there a way to get a full crank revolution? if I do a manual check variable like the one below, will that tally up to the actual crank movements, are there 360 "clicks" in a revolution on the actual hardware?
on crank do
crankdeg++
if crankdeg==360 then
crankdeg=0
end
end
Otherwise, there any accessible variables in relation to the crank, for example crank.position (how many degrees it currently sits at)?
The number does go up to 360, and if you want to count revolutions you'll need to store that in your own variable, probably adding the "ra" value every frame.
Hey @BoldBigflank Yeah I saw that in the docs but don't fully understand it. It seems to imply that the crank doesn't have a "fixed" position or number of clicks logged on the hardware and that the crank is more a relative thing. Unless i'm misinterpreting it.
Try this out. It'll record the total crank angle in a single direction as well as the direction it was turning.
on crank do
if event.ra < 0 then
direction = "backwards"
else
direction = "forwards"
end
if direction != last_direction then
total_cranked = 0
end
total_cranked += event.ra
last_direction = direction
end
on draw do
label "{total_cranked}" at 0,0
label "direction: {direction}" at 0,1
end
Thank you for sharing this! I was able to repurpose this for exactly what I needed.
I'm still working things out, but the idea is that your character attacking uses a charge, and you recharge yourself by using the crank. The code you provided help give me the foundation for making the crank increase the charge. My next step is figuring out the attack stuff.
// Crank Logic
on crank do
if event.ra<0 then
direction = "backwards"
else
direction = "forwards"
end
// if the forward crank is detected, add to the charge.
if direction=="forwards" then
charge++
end
// if the charge is at the maxCharge value, don't go any higher.
if charge>=maxCharge then
charge = maxCharge
end
if direction!=last_direction then
total_cranked = 0
end
total_cranked += event.ra
last_direction = direction
end