Hope you can see the picture and understand the drawings.
It can seem complex at first but you just have to think it through.
I use pythagoras' theorem to find the diagonal of the base square and then use that information along with the height with the aid of that ever so handy pythagoras' theorem to find the length of the slope.