OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lean Bear on 01 Oct 2005, 19:50:38
-
OK, basically in a script I'd like to use the "wait for condition" command '@' for a certain amount of time, say 2 secs, before continuing with the script.
For example:
@(unitDead) // waiting for this variable to be true
...blah blah _unit blah.. // What happens when the variable is true
...more code stuff...
...yackety shamekty...
unitDead = false // reset the variable
#SkipToHere
goto "NextLabel"
I guessing that adapting the @ command isn't possible, so I was wondering if there was a way to do something simple that had the same effect, but only for 2 seconds instead of waiting until the variable is true.
Can I just skip to "SkipToHere" if the variable is still false after 2 seconds?
-
Donno if this is what u look for:
_TimeNow = _time
@(unitDead) or ((_Timenow + 2)<_time)
// waiting for this variable to be true OR 2 seconds delay
?((_Timenow + 2)<_time):goto "SkipToHere"
...blah blah _unit blah.. // What happens when the variable is true
...more code stuff...
...yackety shamekty...
unitDead = false // reset the variable
#SkipToHere
goto "NextLabel"
-
you could use a loop like this
#loop
? variable is true : goto "next"
_loopcount = _loopcount +1
? _loopcount >= 2 : goto "variable still false"
~1
goto "loop"
that should work change the parts needed to what you need
theres probaly an easier way though
-
@ Platoon Patton
Perhaps, if you mean literaly doing what you put in:
_TimeNow = _time
@(unitDead) || ((_Timenow + 2)< _time)
// waiting for this variable to be true OR 2 seconds delay
?((_Timenow + 2)< _time) : goto "SkipToHere"
Does OFP read the +2 on a time value as seconds or what?
Also, I wasn't aware that using 'or' with '@' actually worked, so thanks for that info anyway ;)
@ 456820
A loop has always been an option for me, but I don't really like them, they're so messy and with an already long and complex script I was hoping to find a simpler method, like only adding one or two extra lines. (This will be reapeated a few times throughout the script).
-
Does OFP read the +2 on a time value as seconds or what?
Yep,_time gives the time elapsed since the script started in seconds.
-
OK, I'm a little confused now...
There's 'time' and then there's '_time'.
I know that time will return the game time since the mission began, but I forget what _time does... :-\
Apart from that, great! :)
-
but I forget what _time does...
PP answered this above.
Planck
-
_time is the time since the start of the script
-
Oh right, yeah...whoops :P
time = elapsed time since mission start
_time = elapsed time since script start
got it, thanks ;)
edit
Just out of curiosity, is there any advantage to using either one in this situation?
-
not really any difference i don't think, but generally i would opt for the one that goes with everything else (i.e. _time, pertaining the the script) though you could probably use both...
-
time has (or at least used to have) a bug that it was reset to zero when a saved mission is restarted. I have not seen any reports of _time having the same problem. I always use _time for that reason.
-
OK, you've sold me. I'll stick with _time here. Although, in this case, it wouldn't matter if the time count was reset to zero as I just use it as a point to relate other events from in relation to each other, not to the mission time.
Thanks a bunch 8)