Hey !
I'll be honest, the association of "Call" and "Format" is to me one of the most powerful scripting combination in OFP.
You can do just about anything, especially things that you thought only possible with a limited number of elements. It can shorten scripts considerably, as you seem to have just experienced
.
Now for the explanation (or its attempt
) :
"Call" executes the code that follows.
"Format" enables the inputting of a variable within a given string.
Combining both means that you execute a code within a string, code which may take into account varying numbers.
Here's a not too easy example :
Say you want the last unit of your squad (and him only) to move to your tent called "tent16", out of the twenty tents of the base.
Let's first create the tents, which we'll call "tent1" to "tent20". For this, let's just have a fire called "myfire" :
_i=1
#loop
call format ["tent%1=""campempty"" createvehicle [(getpos myfire select 0)+25*%1,getpos myfire select 1]",_i]
_i=_i+1
? _i<21 : goto "loop"
exit
Execute the code, and here we go ! 20 perfectly aligned open tents, named "tent1" to "tent20".
Now to our loon : regardless of the number of loons I have in my squad, I'll order him this :
call format ["(units group player select %1) commandmove getpos tent%2",(count units group player )-1,16]
And you can combine a potentially unlimited number of arguments...
Just another example, taken from my soon-to-be-released final version of WW2 Pathfinders (this is adverti... :-X) :
call format ["ctrlsettext [120,""%1's Stick Status : (%2 active)""]",name player,count units group player]
With this, I update a dialog by showing the name of the player and displaying the exact number of loons in his squad.
Hoping that I have been clear enough, and that you can now behold the new unlimited horizons of this combination...
Regards,
Igor