First: If load_mainjet() only gets called once, why are you using a For/Each loop to go through all main_jet types when there is only one? Or are you creating new main_jet types somewhere else in your code?
Secondly:
Anyway.....the "for...each" loop for the modification of types is a tricky one.....if it's reset the global to 0 (like what big10p says)it's a terrible problem (for me at least...).
This shouldn't be a problem. Instead of using 'For jet.main_jet=Each main_jet' (which uses the global variable jet for the loop), use a different variable like 'For this_jet.main_jet=Each main_jet'. It's a very bad idea to use loop variables outside of the loop itself - they should be temporary variables just used to iterate through the loop.
Secondly:
Anyway.....the "for...each" loop for the modification of types is a tricky one.....if it's reset the global to 0 (like what big10p says)it's a terrible problem (for me at least...).
This shouldn't be a problem. Instead of using 'For jet.main_jet=Each main_jet' (which uses the global variable jet for the loop), use a different variable like 'For this_jet.main_jet=Each main_jet'. It's a very bad idea to use loop variables outside of the loop itself - they should be temporary variables just used to iterate through the loop.