Hint - use $AddOn_Blah to help.
Also, another thing to improve your coding skills - delete all of the bricks of a certain datablock without looping through the entire mainBrickGroup more than once. (I've already made this, but it helps with learning for loops a lot).
If you've already made it, I won't bother. I'm only making new stuff here. Also, thanks for the tips guys, but I'd prefer to not be given any (not to mention I'm probably a bit more capable with TorqueScript than you seem to think; for example, I am pretty well aquainted with the ins and outs of a for loop). Not trying to be rude, but if there is anything I seriously don't understand, I'll ask in Coding Help. ;)