Home   Help Search Login Register  

Author Topic: Ending a loop  (Read 1601 times)

0 Members and 1 Guest are viewing this topic.

max_killer_payne

  • Guest
Ending a loop
« on: 12 Jul 2003, 15:24:06 »
How can I end a loop, Sui is kindly helping me with this. But scince he cant guarantee it being ready (I need this thing now!!) I was wondering if some1 could help me, and LCD your one didnt work!!  ???
Note than man is a pilot in a plane

Code: [Select]
_cam = "camera" CamCreate [0,0,0]
_cam CameraEffect ["internal","back"]

#loop
_cam camsettarget man
_cam camsetrelpos [0,50,50]
_cam camcommit 0.03
@camcommitted _cam
_cam = _cam + 0.0020
? (_cam> 0.007) : goto "Done"
goto "loop"

#Done
_cam camsettarget man2
_cam camsetrelpos [23,0,56]
_cam camcommit 0
@camcommitted _cam


Whats wrong?
I want it to go to Done after 20 seconds
« Last Edit: 12 Jul 2003, 15:25:51 by max_killer_payne »

Offline KTottE

  • Former Staff
  • ****
Re:Ending a loop
« Reply #1 on: 12 Jul 2003, 16:26:12 »
http://www.ofpec.com/editors/browse.php?browsewhat=2&category=2_12

Use that instead.
It works. It also holds the solution to your problem, though I can't be bothered fetching it for you, just check the script(s) in there.
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

max_killer_payne

  • Guest
Re:Ending a loop
« Reply #2 on: 12 Jul 2003, 16:30:16 »
I cant find anything about ending a loop in there ???

Offline KTottE

  • Former Staff
  • ****
Re:Ending a loop
« Reply #3 on: 12 Jul 2003, 16:36:19 »
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Ending a loop
« Reply #4 on: 12 Jul 2003, 16:38:19 »
Code: [Select]
_cam = "camera" CamCreate [0,0,0]
_cam CameraEffect ["internal","back"]

_I = 0
#loop
_cam camsettarget man
_cam camsetrelpos [0,50,50]
_cam camcommit 0.03
@camcommitted _cam
~0.1
_I = _I+0.1
? _I==20 : goto "Done"
goto "loop"

#Done
_cam camsettarget man2
_cam camsetrelpos [23,0,56]
_cam camcommit 0
@camcommitted _cam

tel me if dat work ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

max_killer_payne

  • Guest
Re:Ending a loop
« Reply #5 on: 12 Jul 2003, 17:26:05 »
Nah, dont work

Rubble_Maker

  • Guest
Re:Ending a loop
« Reply #6 on: 12 Jul 2003, 23:25:58 »
The counter is unreliable coz the @ forces ofp to wait for the camera; no way to predict how many msecs that costs. Also the ~0.1 is not good because ofp will not really wait for 0.1 seconds, it will run the next loop cycle when its *close to 0.1 seconds later AND it is convenient for the engine to do some script execution*. That means: If the engine is too busy doing other stuff, it will neglect the script and the 0.1 delay will get bigger in reality.

Here's a stable solution:

_cam = "camera" CamCreate [0,0,0]
_cam CameraEffect ["internal","back"]
_endTime=TIME+20

#loop
_cam camsettarget man
_cam camsetrelpos [0,50,50]
_cam camcommit 0.03
@camcommitted _cam
_cam = _cam + 0.0020
?TIME<_endTime:goto "loop"

_cam camsettarget man2
_cam camsetrelpos [23,0,56]
_cam camcommit 0
@camcommitted _cam

max_killer_payne

  • Guest
Re:Ending a loop
« Reply #7 on: 13 Jul 2003, 09:30:23 »
cheers Rublemaker

max_killer_payne

  • Guest
Re:Ending a loop
« Reply #8 on: 13 Jul 2003, 10:06:21 »
Shouldnt it be

Code: [Select]
?TIME<_endTime:goto "stopcam"
rather than

Code: [Select]
?TIME<_endTime:goto "loop"

Rubble_Maker

  • Guest
Re:Ending a loop
« Reply #9 on: 13 Jul 2003, 16:13:20 »
No

Think about it! TIME is the seconds passed since the start of the mission. Adding 20  to it goes 20 secs into the future. So as long as the current time is smaller than this value, the loop will go on.