Hi Vlaz,
I don't think you can write a script on the avatar, though you can do something similar if you attach a script to the floor that they're walking over constantly. I did something similar with my game here: https://danwinters.itch.io/heal
Essentially, the floor script had variables that kept the X and Y variables of the avatar generated with {avatar-x} and {avatar-y}. I would then check that variable on the next floor tile against the new values of {avatar-x} and {avatar-y}. For instance, if the previous X variable was 3 and the current {avatar-x} variable is a 4, then I know the avatar has moved right. If it's 4 to 3, then they've moved left. Same thing with the Y variables also.
You can change colors and music, using this like: {set-sprite-color 2}
and {set-music room-1-2 song-2}
. The documentation for those are here: https://github.com/zenzoa/mosi/wiki/Scripts
As for a cycle / loop, I'm not sure there's an easy way around it I'm afraid. It might be possible to do something via 'Custom Scripts' though I'm not sure.