View Single Post
Old 05-03-07, 06:58 PM   #10
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Quote:
Originally Posted by mcoca
Thank you everybody for your support! Now, start using the thing so I can feel I haven't completely wasted my time :p

Quote:
Originally Posted by lurker_hlb3
What would be the code to randomly change speed on each way point i.e pt1 is 5, pt 2 is 8 etc ???
I'm writing from memory, but it would be something along these lines:

Code:
from random import randint
for waypoint in group.waypoints:
    waypoint.speed = randint(2,8)
Obviously, change the numbers to the ones you want. The spaces at the beginning of the third line are important, since python uses indentation to control what's inside the loop and what isn't.

BTW, if you want to get cute, there are functions to provide randomness along a probability curve, so most of the time ships will be around the middle of the range, with the occasional fast or slow one. Check the docs if you are interested.

It worked perfectly, thanks very much
lurker_hlb3 is offline   Reply With Quote