"Stanley could count more than thirty seconds between the flash of lightning and the clap of thunder. That was how far away the storm was"

 Lightning is an electrical discharge that streaks in a bolt from the sky to the ground. This happens when a cloud builds up a high electrical charge. The thunder heard after each bolt is actually the sound of the air around the bolt expanding. This happens at the same time as the lightning, but because sound travels more slowly than light, the flash appears before the thunder is heard.

 

Although speed of sound depends on factors such as humidity, roughly speaking sound travels about 1 mile in 5 seconds. It is therefore possible to estimate how far away lightning is from the time between the flash and the noise. 10 seconds between flash and rumble means the storm is about 2 miles away. More than 30 seconds means that the storm is over 6 miles away from Stanley.