How do I add textures to terrain through scripting?

I’m trying to have a script assigned to the terrain paint textures for me. Is there a tutorial to show me the basics?

Try Procedural Terrain Splatmapping | Alastair Aitchison