what is even going on

So i was still working on my rolling sky remake, but after getting orange arrows to work as a tile, and making them work as a sprite instead, my code had other plans, they just seem to end up modifying completely arbitrary tiles, even though it should work the exact same way as before.

The function is at line 57. (haha funny)