I would explain it, but after 3 attempts at trying I've pretty much given up, but in brief:
1. It sets %c to the length of $1-
2. It checks to see if %c has a value that isn't
0, $null, or $false, if it does have one of those values, it goes to #5.
3. It takes the character in postion %c of $1- and adds it to the end of %r (which at the start of the script is not set, btw).
4. It decreases %c and goes back to #2.
5. It returns the value of %r
The reason for the 2 IFs inside the while loop is because of a limitation with mIRC to do with spaces, which I'm too lazy/stupid to explain