Home   Help Search Login Register  

Author Topic: Sending an Array (or "package of variables") to another script.  (Read 1576 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Hi this is my problem.

The problem is present even in SP, but the script needs to work in MP, therefore posted here.

I have an eventhandler that works. I have tested it with triggers. It is the "receiving" script that fails or the transfer of the array in the eventhandler.

End of lines in eventhandler:
Code: [Select]
_searcherside = getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side");
call compile format ["LAGGY_BodySide%1 = true", _deadguyside];
call compile format ["LAGGY_FinderSide%1 = true", _searcherside];
LAGGY_BodyAndFinderCombo = [format ["LAGGY_BodySide%1,LAGGY_FinderSide%2", _deadguyside,_searcherside]];
publicVariable "LAGGY_BodyAndFinderCombo"; 

According to my testing with triggers it works, but the following "receiving" script doesn't:

Code: [Select]
if (LAGGY_BodySide0 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide0 in LAGGY_BodyAndFinderCombo) then
             {
               hint "An OPFOR body was found by OPFOR";
             };

This last script has multiples of the same lines checking for different combinations, but I thought that would be unnecessary to show, since the lines have the same structure.
The problem is that I never get the hints from the receiving script, so the mistake should be in one of the above examples. My variables are either transferred wrong or received wrong.

IMPORTANT NOTE: I get NO error messages.

If my solution is all messed up, my wish is to send two variables in a "package" or array from the eventhandler.
I then want the recieving script to read the COMBINATION of the variables that come in that "package".

Laggy
« Last Edit: 13 Feb 2009, 19:42:39 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Code: [Select]
LAGGY_BodyAndFinderCombo = [format ["LAGGY_BodySide%1,LAGGY_FinderSide%2", _deadguyside,_searcherside]];
... becomes something like ...

Code: [Select]
LAGGY_BodyAndFinderCombo = ["LAGGY_BodySide0,LAGGY_FinderSide0"];
try { return true; } finally { return false; }

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Thanks a lot for the quick reply,

What does that mean exactly?
Is the problem the " (quotation marks) in the "format broadcast"?

Or was it a question?
If so, yes the variables can be :

LAGGY_BodySide0
LAGGY_FinderSide0

Or do you see another problem?

I have messed with this for days and would be really grateful for some advice.

Laggy
« Last Edit: 13 Feb 2009, 20:01:38 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Take a closer look at it:

LAGGY_BodyAndFinderCombo becomes an array with one element: a single string. But you expect the array to have two elements: two variables.


Try this:
Code: [Select]
LAGGY_BodyAndFinderCombo = call compile format ["[LAGGY_BodySide%1,LAGGY_FinderSide%2]",_deadguyside,_searcherside];
try { return true; } finally { return false; }

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
AHHH,

Thanks, I'll try this out, and see what can be done.

Laggy

EDIT:

Seems to work really well. Because of all the possible combinations, I'll have to return on this subject.

Thanks a lot and a lot so far.

Laggy
« Last Edit: 14 Feb 2009, 01:14:34 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.