Is there any way to paint textures and detail on terrain trough code.

look at the tittle

Projectors?

no no, not projectors>
You know how you can paint a texture on terrain trough the editor well, I want to do the same trough code, like set x y of a terrain to a z texture.

I assume you might be able to modify terrain splat map.

versus

So I assume just “looking at the title” was not enough to deduce what you need. So a little more explanation from your side would have avoided this “confusion”. The more relevant details you give the more likely someone knows what you need.