Home   Help Search Login Register  

Author Topic: Can you use a condition as parameter?  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
Can you use a condition as parameter?
« 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...










Search or search or search before you ask.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Can you use a condition as parameter?
« Reply #1 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?
« Last Edit: 27 Feb 2005, 02:54:39 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Can you use a condition as parameter?
« Reply #2 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)
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Can you use a condition as parameter?
« Reply #3 on: 27 Feb 2005, 03:06:01 »
Whoo-hoo! :wow:  :toocool:
Plenty of reviewed ArmA missions for you to play

Offline Blanco

  • Former Staff
  • ****
Re:Can you use a condition as parameter?
« Reply #4 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  :-[
Search or search or search before you ask.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Can you use a condition as parameter?
« Reply #5 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

I know a little about a lot, and a lot about a little.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Can you use a condition as parameter?
« Reply #6 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
« Last Edit: 27 Feb 2005, 05:05:28 by Triggerhappy »

Offline Blanco

  • Former Staff
  • ****
Re:Can you use a condition as parameter?
« Reply #7 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.

« Last Edit: 27 Feb 2005, 06:45:30 by Blanco »
Search or search or search before you ask.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Can you use a condition as parameter?
« Reply #8 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
I know a little about a lot, and a lot about a little.