OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: _Ross_ on 19 Jun 2003, 06:30:33
-
I know this sounds really dumb, But I have no Idea how to make a working loop, and I cant find a TUT. A quick crash course in loops would be great.
maybe an example loop ;D
thanks ;D
-
I think it could be something like:
;Chris and the script loop tutorial
#Script Tute
?(! Alive) Chris :goto "End"
Chris Sidechat "Hey guys, we should check out Johann Gustafson's Script tutorial!"
~5
goto "Script Tute"
#End
exit
This would have you talking about that tutorial every 5 seconds until you were dead! :P
...though my syntax might be off in there somwhere .. ;D :tomato:
-
yeah - u have prob w/ syntax :P
#Script Tute
cant put spaces in dere :P
?(! Alive) Chris :goto "End"
not prob but its shorter just 2 put
?(! Alive) Chris : exit
dats all i think ;D
LCD OUT
-
IÂ've always used !(alive chris)... Not (! alive) chris, or that doesnÂ't matter?
-
yeah - u have prob w/ syntax :Pcant put spaces in dere :Pnot prob but its shorter just 2 put
?(! Alive) Chris : exit
dats all i think ;D
LCD OUT
Ya . I be Knowed I done screwed the pooch on dat one, but didn't you like my example. ;) ;D
-
iÂ've always used !(alive chris)... Not (! alive) chris, or that doesnÂ't matter?
i use not alive chris w/o () nd it doesnt realy matter ;D ;)
Ya . I be Knowed I done screwed the pooch on dat one, but didn't you like my example
donno - never used dat TUT (learned scriptin by expirment n depboin misions - i never used TUTs :P 8)
LCD OUT
-
Umm, Im still not clear on where the condition under which the loop ends goes
-
Umm, Im still not clear on where the condition under which the loop ends goes
Umm ....Ross ...you're not GUN crazy, are you? ;D :-X
Okay, here's an example that some fine folks on here helped me with.
;CONDITIONAL JOIN SCRIPT
#Count
P1 SideChat "started"
_n=("alive _x" count units Colgrp)
?_n<11:goto "Join"
P1 SideChat "counted 11 and waiting 60"
~60
P1 SideChat "Waited and Restarting"
Goto "Count"
#Join
P1 SideChat "Waiting to join"
~12
[PMH6,GMH6] join Colgrp
Exit
This script helped me understand it a little better.
All the stuff in TEAL COLOR I added so I could see what was going on with the script when I was testing it ...very helpful! The BLUE stuff is telling the script where to go or what to do after it figures out the condition. In this case, 2 pilots have executed this script to see if any of the leader's original 11 members have died. If not, they wait 60 seconds and count again......i.e. looping back to #COUNT. If so, they goto the #Join part , wait 12 seconds and then JOIN the leader's group. Works great. :) Hope that helps you.
-
Check that file
http://www.ofpec.com/yabbse/attachments/AAartilery2.sqs
There is nice and easy loop with codition. It stops running when ammo ( _rounds ) is off. In fact it runs as long as the amount of _rounds parameter is above 0.
-
Crash course in loops:
Scripts work from up down. What a loop does is jump the "active" part of the script back up again, making it do the stuff between again. As you've seen:
#Loop
hint "Looping"
~1
goto "Loop"
the pertinent things are the #Loop and the goto commands. The above loop would loop in all eternity, displaying the hint "Looping" every second. The point where the loop stops is up to you. Say you make a radio command, Radio Alpha, with the on Activation: loopstop=true
then add
#Loop
?Loopstop : exit
hint "Looping"
~1
goto "Loop"
and the loop will stop and the script exit as soon as Loopstop is true.
And yeah. You should read Johann Gustafson's scripting manual. It's the best. :thumbsup:
Wolfrug out.