This ^
They say you should spend 50% of development time planning your program out, think of this as the building blocks of your script. You don't want to build a house with a shitty foundation
The best way of planning it out, do what you are gonna do manually, and write down everything you do.
If you went down a set of stairs, you'll need that.
if you walked somewhere, you'll need that.
write everything down!