Home   Help Search Login Register  

Author Topic: addaction & and passing values to script  (Read 771 times)

0 Members and 1 Guest are viewing this topic.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
addaction & and passing values to script
« on: 12 Mar 2004, 05:33:22 »
Is there anyway that addaction can pass a value to the script that is called?  I know I can do something like:

Code: [Select]
act = player addaction ["Hello","hello.sqs"]

but how about someting like this?

Code: [Select]
act = player addaction ["Hello",{[soldier1,soldier2] exec "hello.sqs"}]

I tried this but it did not work, but maybe it is my syntax?

Any help is appreciated. Thanks.

j-man

  • Guest
Re:addaction & and passing values to script
« Reply #1 on: 12 Mar 2004, 08:10:56 »
Mabey something like:

Persons init field:
Code: [Select]
act = player addaction ["Hello","jman.sqs"]
jman.sqs:
Code: [Select]
[soldier1,soldier2] exec "hello.sqs"
~0.1
exit

hello.sqs:
Code: [Select]
whatever you want...
« Last Edit: 12 Mar 2004, 08:11:55 by j-man »

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:addaction & and passing values to script
« Reply #2 on: 12 Mar 2004, 09:52:34 »
OK thanks but I was hoping to avoid using a script to start a script, which is how I've always done it with addaction.  Often one is forced to have the addaction start a script which just sets a booleen flag, but for complex scripting this get so messy.  Anyway, thanks.  Maybe I could use an eventhandler in conjunction with addaction?  Is there an eventhandler event associated with addaction?  Probably not.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:addaction & and passing values to script
« Reply #3 on: 12 Mar 2004, 10:33:28 »
As far as I know the two script method is the only way.
Not all is lost.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:addaction & and passing values to script
« Reply #4 on: 12 Mar 2004, 13:34:55 »
It is.  Unless of course soldier1 and soldier2 are part of the action.  Ie, Soldier1 is the name of the unit that the action is on, and soldier2 is teh name of the unit that activates the unit.  In which case they are automatically passed.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:addaction & and passing values to script
« Reply #5 on: 12 Mar 2004, 15:52:30 »
If that is true that is very good news!  OK, if they are automatically passed, what is the format to access it?  Is it the normal method of array retrieval in the script that is initiated by the action? I.E.:

_x = _this select 0;
_y = _this select 1;

And if this is the method of retrieval, would _x (select 0) be the one doing the action?

Thanks

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:addaction & and passing values to script
« Reply #6 on: 12 Mar 2004, 15:55:02 »
I will do a test script to try to figure out the above question, but if someone knows off-hand, that would save me time.

Thanks Again.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:addaction & and passing values to script
« Reply #7 on: 12 Mar 2004, 16:07:36 »
select 0 is the name of the unit the action is on.

select 1 is the name of the unit that has activated the action.

So having

_x = _this select 0

_y = _this select 1

_x would refer to the action holder.
_y would refer to the action activater.

Rappy

  • Guest
Re:addaction & and passing values to script
« Reply #8 on: 12 Mar 2004, 16:10:00 »
To see which values are passed just do an action

in the script have

_value0 = _this select 0
_value1 = _this select 1
_value2 = _this select 2
etc

then

Hint format ["first value %1, second value %2, Third value %3", _value0, _value1, _value2]

And see what comes up

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:addaction & and passing values to script
« Reply #9 on: 13 Mar 2004, 04:33:17 »
Thanks,

 I did do a test (similar to what you suggested Rappy).  I have a handle on it now.