Home   Help Search Login Register  

Author Topic: loops  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

_Ross_

  • Guest
loops
« 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

« Last Edit: 19 Jun 2003, 06:57:57 by _Ross_ »

Mr.BoDean

  • Guest
Re:loops
« Reply #1 on: 19 Jun 2003, 08:23:13 »
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:
« Last Edit: 19 Jun 2003, 08:25:02 by Mr.BoDean »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:loops
« Reply #2 on: 19 Jun 2003, 08:47:07 »
yeah - u have prob w/ syntax :P

Quote
#Script Tute

cant put spaces in dere :P

Quote
?(! Alive) Chris :goto "End"

not prob but its shorter just 2 put

?(! Alive) Chris : exit

dats all i think ;D

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

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:loops
« Reply #3 on: 19 Jun 2003, 09:21:45 »
IÂ've always used !(alive chris)... Not (! alive) chris, or that doesnÂ't matter?

Mr.BoDean

  • Guest
Re:loops
« Reply #4 on: 19 Jun 2003, 09:40:06 »
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

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:loops
« Reply #5 on: 19 Jun 2003, 10:22:31 »
Quote
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 ;)

Quote
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
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

_Ross_

  • Guest
Re:loops
« Reply #6 on: 19 Jun 2003, 19:39:23 »
Umm, Im still not clear on where the condition under which the loop ends goes

Mr.BoDean

  • Guest
Re:loops
« Reply #7 on: 20 Jun 2003, 14:07:18 »
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.


HiReZ

  • Guest
Re:loops
« Reply #8 on: 21 Jun 2003, 15:32:41 »
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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re:loops
« Reply #9 on: 22 Jun 2003, 00:32:29 »
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.
"When 900 years YOU reach, look as good you will not!"