Running several events at the same time
Posted: Fri Jan 08, 2010 10:26 pm
Hi Forum,
I was trying to run several events practically at the same time in order to test this capability for some more involved development. In fact I had 10 cars running along 3 routes and my first attempt was succesful but not elegant. This is what I have done for each car:
on moveMe
if not the uAllowMove of me the exot moveMe
#Calculation of the coordinates of the next point and the time between the points (i.e. time of travelling between two points, denoted as "tSecs"), and then using
set loc of me to xLoc, yLoc
send "moveMe" to me in tSecs seconds
send "showTime" ~ this was for the time loop; pls see below.
end moveMe
This moves the object in "jumps" or steps and waits for the required timne of passage. However, I then found out that I could use "move" command so instead of "set loc of me .." and "send "moveMe" to me in tSecs", I utilised the following code:
move me to Xloc,yLoc in tSecs seconds
send "moveMe" to me in 10 milliseconds #Tried without any milliseconds, and then up to 5 seconds)!
This second version was more elegant when one car was tested (because the nobject has nearly continuous movement), but started to misbehave as soon as 10 cars were introduced. Not only that some objects disapeared along the route, but some cars jumped a few route segments.
Could someone explian the following:
1. reasons for such different behavious when using "move" command; Is there a better way to use "move" command?
2. what is the best way to run and control several objects doing something, interacting, etc at the same time;
3. best ways for the time "loop". I used "on showTime / end showTime" on the card, and "send "showTime" in the script for each object.
Please note that I find object oriented programming quite difficult (but atractive).
Many thanks.
Best regards,
Vladimir
I was trying to run several events practically at the same time in order to test this capability for some more involved development. In fact I had 10 cars running along 3 routes and my first attempt was succesful but not elegant. This is what I have done for each car:
on moveMe
if not the uAllowMove of me the exot moveMe
#Calculation of the coordinates of the next point and the time between the points (i.e. time of travelling between two points, denoted as "tSecs"), and then using
set loc of me to xLoc, yLoc
send "moveMe" to me in tSecs seconds
send "showTime" ~ this was for the time loop; pls see below.
end moveMe
This moves the object in "jumps" or steps and waits for the required timne of passage. However, I then found out that I could use "move" command so instead of "set loc of me .." and "send "moveMe" to me in tSecs", I utilised the following code:
move me to Xloc,yLoc in tSecs seconds
send "moveMe" to me in 10 milliseconds #Tried without any milliseconds, and then up to 5 seconds)!
This second version was more elegant when one car was tested (because the nobject has nearly continuous movement), but started to misbehave as soon as 10 cars were introduced. Not only that some objects disapeared along the route, but some cars jumped a few route segments.
Could someone explian the following:
1. reasons for such different behavious when using "move" command; Is there a better way to use "move" command?
2. what is the best way to run and control several objects doing something, interacting, etc at the same time;
3. best ways for the time "loop". I used "on showTime / end showTime" on the card, and "send "showTime" in the script for each object.
Please note that I find object oriented programming quite difficult (but atractive).
Many thanks.
Best regards,
Vladimir