Jump to content
Sign in to follow this  
Tankbuster

while doesnt work in a call compile format?

Recommended Posts

I've been staring at this for a few days now without figuring out what is broken, so I thought I'd ask you guys.

I have a while statement that needs to use a flag with a dynamic variable name.

This works;

while { iris_active_0 } do {

and that's fine. But the script needs to work with a number of flags, namely iris_active_1, iris_active_2 etc etc

So i tried this,

call compile format ["while { iris_active_%1 } do {", _serial];

But it gives an error;

2014/06/22, 22:16:39 Error in expression <while {iris_active_0} do>
2014/06/22, 22:16:39   Error position: <>
2014/06/22, 22:16:39   Error Invalid number in expression

_serial is a scalar number, I checked in debug.

So, 2 questions, why isn't it working as expected and is there a better way of doing this?

Thanks in advance,

Tanky -Paul-

Share this post


Link to post
Share on other sites

while{call compile format ["Iris_Active_%1",_serial]}do

{

..............

};

Share this post


Link to post
Share on other sites

You can also put the loop inside of a [] spawn {}

Share this post


Link to post
Share on other sites

That's got it, Terox! Thanks mate. :)

Share this post


Link to post
Share on other sites

You could also replace call compile with missionNamespace getVariable if your workking with global variables

while{missionNamespace getVariable (format ["Iris_Active_%1",_serial]) ] }do
{
..............
}; 

Share this post


Link to post
Share on other sites

Yes, I was thinking about this method, Larrow. These variable are global, public, in fact and so I have been mulling over replacing much of my call compile format with setvariable. I was going to put an object in each of the locations that iris works on (it's Island Random Incident System BTW) and store the flag there using setvariable.

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  

×