OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: max_killer_payne 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
_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
-
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.
-
I cant find anything about ending a loop in there ???
-
Wrong URL from me.
http://www.ofpec.com/editors/resource_view.php?id=152
-
_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
-
Nah, dont work
-
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
-
cheers Rublemaker
-
Shouldnt it be
?TIME<_endTime:goto "stopcam"
rather than
?TIME<_endTime:goto "loop"
-
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.