Home   Help Search Login Register  

Author Topic: Counter hell!  (Read 529 times)

0 Members and 1 Guest are viewing this topic.

cpt.Hawkeyez

  • Guest
Counter hell!
« on: 23 Jan 2003, 20:14:38 »
Okay heres the problem I'm not sure how to do this because I want this script to cycle through 80 times before going back up to start this is the script

#start
_flare = "flare" camCreate [getpos frank this select 0, getpos frank this select 1, (getpos frank this select 2)+1.7]
~0.01
_counter this select 0

#loop1
_flare [getpos frank this select 0, getpos frank this select 1, (getpos frank this select 2)+1.7]
_flare setvelocity = [0,0,1]
~0.20
_counter + 1

?_counter == 80 goto "start"

exit

now I'm not sure about the counter part how do I make it so that everytime the loop starts over it adds +1 to the counter and when the counter is equal to 80 the script goes back up to start as you can see. Thanks also not to sure about the velocity part correct me if I'm wrong

CymPaTheeY
« Last Edit: 23 Jan 2003, 20:17:14 by CymPaTheeY »

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Counter hell!
« Reply #1 on: 23 Jan 2003, 21:43:48 »
Change:

_counter + 1

To:

_counter = _counter + 1

Also, add:

goto "loop1"

before your line with exit.

This will work exactly how you'd like it to, assuming that the first element in the array that you are passing to your script has a value of 80.

For setVelocity, did you read the description of it in the Com Ref?  Don't just guess at how to use these commands!

vehicle setVelocity [x, z, y]
Operand types:
    vehicle: Object
    [x, z, y]: Array
Type of returned value:
    Nothing
Compatibility:
    Version 1.8 required.

Description:
    Set velocity (speed vector) of vehicle.

Example:

_flare setvelocity [0,0,1]
Ranger

cpt.Hawkeyez

  • Guest
Re:Counter hell!
« Reply #2 on: 24 Jan 2003, 00:16:51 »
so this is the right way
Code: [Select]
#start
_flare = "flare" camCreate [getpos frank this select 0, getpos frank this select 1, (getpos frank this select 2)+1.7]
~0.01
_counter this select 0

#loop1
_flare [getpos frank this select 0, getpos frank this select 1, (getpos frank this select 2)+1.7]
_flare setvelocity [0,0,1]
~0.20
_counter = _counter + 1

?_counter == 80 goto "start"

goto "loop1"

exit

Yeah well the reason its 80 is because 80*0.2=16.8 and the life of a flare is 17 seconds so the script will go for 16.8 and then create a new flare right. Also thanks for the help

CymPaTheeY

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Counter hell!
« Reply #3 on: 24 Jan 2003, 18:24:35 »
I just noticed one other small error.  Change the following line:

?_counter == 80 goto "start"

to:

?_counter == 80 : goto "start"

Otherwise, your script appears to be correct, now.

No prob for the help.

By the way, why are you bothering to set the velocity of the flare when you are constantly resetting it's position, anyway?
Ranger

cpt.Hawkeyez

  • Guest
Re:Counter hell!
« Reply #4 on: 24 Jan 2003, 19:20:57 »
I dunno artak told me to put it there so it doesnt fall down during the 0.2 seconds.

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Counter hell!
« Reply #5 on: 24 Jan 2003, 21:23:36 »
Okay.  In any event, it's fine to do that, I was just wondering what the purpose was.  I suppose with a 0.2 second delay, that's a good idea.  If you had a shorter (or no) delay, you wouldn't need to set the velocity.
Ranger

cpt.Hawkeyez

  • Guest
Re:Counter hell!
« Reply #6 on: 25 Jan 2003, 04:21:24 »
Ohh ok thanks