Jump to content
Sign in to follow this  
zodd

Multiple calls of a script held as an array

Recommended Posts

Gday all,

I have a script which is working very well for a single call (allows user to pass information to set up a gun unit with type of round, accuracy, ammo etc)

What I am looking at doing is extending the script to allow multiple different instances...

My plan - Add an integer to the call and change all the variables in the script to array types

eg. (simplified for concept)

CURRENT:

[gun, rounds, ammo] execVM "myscript.sqf";

which creates the following var: (eg)

trigger_adjust

trigger_fire

ammo

Can I amend the whole script to something like:

[positioninarry, gun, rounds, ammo] execVM "myscript.sqf";

which creates the following var: (eg)

trigger_adjust[positioninarray]

trigger_fire[positioninarray]

ammo [positioninarray]

Is this functional or is there an easier way?

I will do some more experimenting when I can but keen to avoid reinventing the wheel if possible as the current script series is fairly large!

Much appreciated!

Share this post


Link to post
Share on other sites

You could do that with a variable in the script:

No need to do that outside of the script, you can change the variables each time it runs with conditions and control structures:

_scriptRuns = 0;
_scriptRuns = _scriptRuns +1;
_number = str(_scriptRuns);

switch (_number) do {
case "0" : {
change variables here......
};
case "1" : {
change variables here......
};
case "2" : {
change variables here......
};
};

http://community.bistudio.com/wiki/Control_Structures#switch-Statement

http://community.bistudio.com/wiki/Variables

You could build an array within a script to execVM, Call or Spawn another script with (not tested this but it should work):

http://community.bistudio.com/wiki/Array#Addition

_array1 = [[0,0,0]];
_array2 = [gun, rounds, ammo];
_array3 = _array1 + _array2
//_array3 will return [[0,0,0],gun, rounds, ammo];
_array3 execVM "somethingsomethingdarkside.sqf";

Edited by PELHAM

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×