OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: penguinman on 26 Feb 2005, 06:00:32

Title: velocity, and scripts
Post by: penguinman on 26 Feb 2005, 06:00:32
?! _speed = [0,0,0] : goto "loop"

why does that line in my script bring up error,

o and speed is

_speed = velocity _man

and man is

_man = _this select 0

thanks penguin
Title: Re:velocity, and scripts
Post by: UNN on 26 Feb 2005, 06:09:33
You cant make a direct comparison with arrays, so you cant say array1==array2.

But there is a shorcut, you can subtract one lot of array elemts from another, so:

Code: [Select]
Count (_Speed-[0,0,0])
Will return 0 if the object your testing is not moving.
Title: Re:velocity, and scripts
Post by: penguinman on 26 Feb 2005, 07:15:33
thx
Title: Re:velocity, and scripts
Post by: penguinman on 26 Feb 2005, 07:19:40
hmm still geting an uknown operator error,

im using

Count (_Speed-[0,0,0]) : goto "loop"


the # is here

Count (_Speed-[0,0,0])|#| : goto "loop"
Title: Re:velocity, and scripts
Post by: THobson on 26 Feb 2005, 07:56:11
I think, to do what you are trying to do the construct should be something like:

if ({_x == 0} count  _speed == 3) then {whatever}

This might get rid of the error, but will not really do what you want because the array elements returned by velocity are real numbers not integers.  The chance of them being exactly 0 is very small indeed and cannot be relied on.  Why not use:

_speed = speed man
if (_speed <0.1) then {whatever}

If you must use velocity then try:

_speed = velocity man
if ({abs(_x) < 0.1} count  _speed == 3) then {whatever}

Title: Re:velocity, and scripts
Post by: penguinman on 26 Feb 2005, 09:03:51
*smacks head against computer screen*

how stupid of me, "speed"

i wasted alot of time when all i had to use was speed, not set velocity.

thank you
Title: Re:velocity, and scripts
Post by: penguinman on 26 Feb 2005, 09:30:13
ok but how do u get a script to wait at a certain point until somthing has happend,

like say i wanted a script to set dammage 1 one guy say m1

then make another guy m2 go prone "setunitpos"


then wait until a third guy m3 has started moving using speed.

and once the third guy has started moving the script will setdammage 1, one last man, m4

how and what would that look like


and it needs to be with out using loops

but if its not posible without loops then how with loops

thanks
Title: Re:velocity, and scripts
Post by: macguba on 26 Feb 2005, 11:13:00
As long as their are no enemy around then a doStop command sounds like it will do what you need.
Title: Re:velocity, and scripts
Post by: THobson on 26 Feb 2005, 11:54:50
you could try putting the following in your script:

@(speed m3 > 0.1)
Title: Re:velocity, and scripts
Post by: penguinman on 26 Feb 2005, 20:17:18
ya, umm, isnt do stop for units, it wouldnt make a script wait???


say i were to script that simple example i gave, what would that look like

Quote
say i wanted a script to set dammage 1 one guy say m1

then make another guy m2 go prone "setunitpos"


then wait until a third guy m3 has started moving using speed.

and once the third guy has started moving the script will setdammage 1, one last man, m4


thanks
Title: Re:velocity, and scripts
Post by: macguba on 26 Feb 2005, 20:53:40
Sorry yes I misread your post.
Title: Re:velocity, and scripts
Post by: penguinman on 27 Feb 2005, 02:05:02
lol yes,
but how would it be done,

if i must i will post the entire script but i would rather not as theres alot of stealers around here and i want to submit it
Title: Re:velocity, and scripts
Post by: THobson on 27 Feb 2005, 08:49:30
Did my suggestion at #8 above not work?
Title: Re:velocity, and scripts
Post by: penguinman on 27 Feb 2005, 22:16:50
im not sure how to implement that

thanks
Title: Re:velocity, and scripts
Post by: THobson on 27 Feb 2005, 23:27:07
You put it in your script and you script will stop at that point until the speed of m3 is > 0.1  When that becomes true the script will continue to run.
Title: Re:velocity, and scripts
Post by: penguinman on 08 Mar 2005, 06:51:03
ok, thanks, i have it like this


@ (speed _man >0.1) : goto "loop"

but i get a unknown operator error,

the # is here

@ (speed _man >0.1)# : goto "loop"

thanks
Title: Re:velocity, and scripts
Post by: THobson on 08 Mar 2005, 10:57:16
@ is not an if statement.  It just stops the script until the condition is true.  So the follwoing should not give you an error

@ (speed _man >0.1)
goto "loop"

The script will wait at the @ statement until the condition is true.  Once it becomes true the script will continue running at the next line
Title: Re:velocity, and scripts
Post by: StonedSoldier on 08 Mar 2005, 13:12:57
or try;

?(speed _man) >0.1 : goto "loop"
Title: Re:velocity, and scripts
Post by: ACF on 08 Mar 2005, 13:52:40
?(speed _man) >0.1 : goto "loop"

It's not the same as an @ command. If/? won't hold the script, if speed _man < 0.1, the script will just continue, maybe exit, and the loop will break.
Title: Re:velocity, and scripts
Post by: StonedSoldier on 08 Mar 2005, 14:44:16
Code: [Select]
#loop
?(speed _man) >0.1 : goto "loop"
hint "The unit is stationary"

there you are, that wouldnt break
Title: Re:velocity, and scripts
Post by: ACF on 08 Mar 2005, 18:16:14
Er, yes...but we don't want to go to the original #loop until Speed _man > 0.1, so if we're insisting on a 'looped if'solution:

Code: [Select]
#checkloop
~1
?((speed _man) =< 0.1): Goto "checkloop"
hint "The unit is no longer substantially stationary"
goto "loop"
It was also an unrestricted loop which is bad, lag-inducing practice; if we're trying to inform and educate (or be pedantic).

Code: [Select]
@ (speed _man >0.1)
goto "loop"
does the job in a far simpler way.