is it possible to make an event that keeps moving until it hits a wall?

hi,im trying to make a puzzle in my game where you have to push a ball that when you interact with it it keeps moving until it hits a wall and you have to push the ball into a button(kinda like the gooftroop snes game puzzles),so how could i do that? i tried to make a movement route that reapeats and that also skips if it cannot move but it didnt work
Option A: Force a move route with like a hundred 'move lefts' and make them skippable, so it'll eventaully finish skipping them all

Option B: check to see if you're touching a wall after each movement using $gameMap.ispassable(this.x,this.y,directionYou'reTravelling) and flip a switch or something if it's no longer passable

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-make-an-event-that-keeps-moving-until-it-hits-a-wall.122876/