in reply to help figuring out what a section of script does

G'day michaelsingleton,

Welcome to the Monastery.

While myself and others would be more than happy to help you, your post, as it is currently presented — all code and commentary as a single line of paragraph text — is virtually unreadable.

Please put plain text in <p>...</p> tags; and code and data in <code>...</code> tags.

There's more information about this in "Writeup Formatting Tips" and "How do I post a question effectively?".

— Ken