So, after looking into the forums I found that there were no answers to moving the player with the crank. So I took it into my own hands to figure it out. Thanks to Scarboy for posting about checking for crank rotations!
So first, what you want to do is go down to the player script and add this script:
on update do
// This will check if you hit the d-pad.
if event.dy==-1 then
stats = 1
emit "stats1"
elseif event.dy==1 then
stats = 2
emit "stats2"
elseif event.dx==1 then
emit "stats3"
stats = 3
elseif event.dx==-1 then
emit "stats4"
stats = 4
end
end
After you put this in, add this section directly below it:
// this will tell you the crank direction.
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
Thanks, Scarboy for this section of code as it was essential to me figuring this out.
Add this section in right below:
on draw do
// This checks if the total cranked was at 100
if total_cranked>=100 then
// this simply tells you it’s registering (for troubleshooting)
label "do it" at 15,7
if stats==1 then
total_cranked = 0
emit "Move1"
elseif stats==2 then
emit "Move2"
total_cranked = 0
end
if stats==3 then
emit "Move3"
total_cranked = 0
end
if stats==4 then
emit "Move4"
total_cranked = 0
end
end
Now that we have all of this we are onto the last section of our tough journey. Add this to the object you wish to move. I think this script works best when applied to something other than the player because you don’t have to cancel out d-pad movement. If you’re up for it, I think you can find other scripts on here to explain cancelling out d-pad movement.
// If you ever find an “idk” replace that with the title of the object you wish to move
on Move1 do
targetX = event.x
targetY = event.y
targetY += 1
swapTarget = "idk"
swap "white"
tell targetX,targetY to
swap swapTarget
end
end
on Move2 do
targetX = event.x
targetY = event.y
targetY -= 1
swapTarget = "idk"
swap "white"
tell targetX,targetY to
swap swapTarget
end
end
on Move3 do
targetX = event.x
targetY = event.y
targetX += 1
swapTarget = "idk"
swap "white"
tell targetX,targetY to
swap swapTarget
end
end
on Move4 do
targetX = event.x
targetY = event.y
targetX -= 1
swapTarget = "idk"
swap "white"
tell targetX,targetY to
swap swapTarget
end
end
After you do all this you should be able to move the player/ object with the crank. Unfortunately, you’re going to have to freeze the player’s default d-pad movement script. I think I have figured it out but I hope you see how easy it may be. If you can’t figure it out, comment your Cancel Default Movement section of the script and I’ll get back to you as soon as I can on how to fix it (If I can). I hope this helped you! Tell me if this doesn’t work and I’ll try and see what’s wrong.