OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 27 Feb 2005, 02:48:45

Title: Can you use a condition as parameter?
Post by: Blanco on 27 Feb 2005, 02:48:45
I wanna know if it's possible to use a simple condition line as parameter to execute a script?

something like this:

[unit1, (getdammage unit2 > 0.5)] exec "script.sqs"

I tried it with

call _this select 1

but it doesn't work...










Title: Re:Can you use a condition as parameter?
Post by: macguba on 27 Feb 2005, 02:53:42
I am famous, at least with me, for my ignorance on scripting matters.    Consequently, no matter how embarrassng the following is, I'm not embarrassed.

Could you pass the conditional bit as a string, and then un-string it in the script?
Title: Re:Can you use a condition as parameter?
Post by: General Barron on 27 Feb 2005, 02:58:52
macguba is correct. What you are doing is passing the true/false result of that condition to the script. Using a boolean with the "call" command will cause an error. Instead, pass it as a string, and then use the "call" command on it:

[unit1, "getdammage unit2 > 0.5"] exec "script.sqs"

_damaged = call (_this select 1)
Title: Re:Can you use a condition as parameter?
Post by: macguba on 27 Feb 2005, 03:06:01
Whoo-hoo! :wow:  :toocool:
Title: Re:Can you use a condition as parameter?
Post by: Blanco on 27 Feb 2005, 03:46:16
I tried it that way General, but nothing happens, no errors, just nothing...


[this,"Getdammage unit2 > 0"]  exec "script.sqs"

Code: [Select]
_damaged = call (_this select 1)

#loop
?_damaged : hint "ok":exit
~1
goto "loop"

I killed unit2, but no hint  :-[
Title: Re:Can you use a condition as parameter?
Post by: Planck on 27 Feb 2005, 03:53:21
Just a thought but when this line is executed:

[this,"Getdammage unit2 > 0"]  exec "script.sqs"

Won't that make 'select 1' equal to 0, as he is still alive at that time.

Possibly you need to take:

_damaged = call (_this select 1)

and put it inside the loop.


Planck

Title: Re:Can you use a condition as parameter?
Post by: Triggerhappy on 27 Feb 2005, 05:04:45
just thinking aloud... can you assign a condition to a variable?

_dammaged = _this select 1
#loop
?(call _damaged) : hint "ok":exit
~1
goto "loop"

that looks better to me
Title: Re:Can you use a condition as parameter?
Post by: Blanco on 27 Feb 2005, 06:32:35
Wohoo! It works! Thx a lot! (all of ya)

Planck is right. Very nice... :)

PS: I also tried your code Triggerhappy, it doesn't work, at least not in my example.

Title: Re:Can you use a condition as parameter?
Post by: Planck on 27 Feb 2005, 12:03:35
Did you copy TriggerHappy's code via cut and past?

He has a titchy little typo there:

_dammaged.......and then

_damaged.

If you didn't copy/paste it just ignore me.


Planck