Jump to content

Recommended Posts

good afternoon all guys I have a question and I wanted to ask, if I have a spawn with a while, how many rest periods I can have inside, example:

 

Iniciador = [] Spawn 

{

while {true} do {

if ((getposASLW _vehicle select 2) < -25) then { 

[] spawn {

trigger = createTrigger ["EmptyDetector", getPos cubo]; 

Sleep 10;

deletevehicle SilencioA0;


removeallactions bo57;

                        }; 

                 };

            Sleep 1
            };

            

            
};

 

my question would be if the first sleep 10 will affect the repetition time of the while?

 

Share this post


Link to post
Share on other sites

wouldn't the 'sleep 10;' only apply to the code in the 'spawn {code}' part? my money is on the loop will repeat every second.

 

if you add a debug hint you should be able to see:

 

Spoiler

 Iniciador = [] Spawn

{

 _c = 0;

 while {true} do {

                if ((getposASLW _vehicle select 2) < -25) then {

                [] spawn {

                        trigger = createTrigger ["EmptyDetector", getPos cubo];

                        Sleep 10;

                        deletevehicle SilencioA0;


                        removeallactions bo57;

                        };

                 };

                hint str _c;

                _c = _c +1;

                Sleep 1;
        };

            

            
};

 

Share this post


Link to post
Share on other sites
26 minutes ago, elthefrank said:

good afternoon all guys I have a question and I wanted to ask, if I have a spawn with a while, how many rest periods I can have inside, example:

 

Iniciador = [] Spawn 

{

while {true} do {

if ((getposASLW _vehicle select 2) < -25) then { 

[] spawn {

trigger = createTrigger ["EmptyDetector", getPos cubo]; 

Sleep 10;

deletevehicle SilencioA0;


removeallactions bo57;

                        }; 

                 };

            Sleep 1
            };

            

            
};

 

my question would be if the first sleep 10 will affect the repetition time of the while?

 

This looks sketchy as hell.

The while true loop will run every second, creating a trigger every second when the _vehicle is 25m below water.

_vehicle also is undefined inside the scope you're using it.

Did this even work when you tried it?

 

What do you want to achieve?

 

Also post using code tags and proper indentation, makes it easier to go through.

 

Cheers

Share this post


Link to post
Share on other sites

ok you're right, see if the spawn is executed once without the while, it will not run again is it true? in this way:

I will make it more complete so that I have an idea, if it has worked for me but I wanted to know if the triguer would be created doubly if the condition is repeated?

in this case I will raise it without the while

 

Iniciador = [] Spawn 

{

if ((getposASLW _vehicle select 2) < -25) then { 

[] spawn {

trigger1 = createTrigger ["EmptyDetector", getPos cubo]; 

    };

}; 


if ((getposASLW _vehicle select 2) < -45) then { 

[] spawn {

deletevehicle trigger1;

Sleep 5;

trigger2 = createTrigger ["EmptyDetector", getPos cubo]; 


                   }; 

          };
          
          
if ((getposASLW _vehicle select 2) < -85) then { 

[] spawn {

deletevehicle trigger2;

Sleep 5;

trigger3 = createTrigger ["EmptyDetector", getPos cubo]; 


                   }; 

          };
          

if ((getposASLW _vehicle select 2) > -83) then { 

[] spawn {

deletevehicle trigger3;

Sleep 5;

trigger2 = createTrigger ["EmptyDetector", getPos cubo]; 


                   }; 

          };
          
if ((getposASLW _vehicle select 2) > -43) then { 

[] spawn {

deletevehicle trigger2;

Sleep 5;

trigger1 = createTrigger ["EmptyDetector", getPos cubo]; 


                   }; 

          };
          
if ((getposASLW _vehicle select 2) > -23) then { 

[] spawn {

deletevehicle trigger1;


                   }; 

          };
 
};

 

my intention is to create an area of smaller distance every time that it gets lower, and when it goes up it eliminates the previous distance and creates the new one according to the depth, but my question is if I apply the while, being in the place while will I create the same trigger several times?

 

Share this post


Link to post
Share on other sites

Would there be the possibility that it recognizes a variable already created and does not recreate it?

Share this post


Link to post
Share on other sites

Another question aside guys, could you call this this way too?

 

if ((getposASLW _vehicle select 2) < -25 and > -43)

 

it is valid?

Share this post


Link to post
Share on other sites
1 hour ago, elthefrank said:

Another question aside guys, could you call this this way too?

 

if ((getposASLW _vehicle select 2) < -25 and > -43)

 

it is valid?

 

That's not proper syntax.

Would look like this:

 if ((getposASLW _vehicle select 2) < -25 and (getposASLW _vehicle select 2) > -43) 

No idea where you getting at,

you mention a smaller area depending on depth, yet your example doesn't show anything similar.

Also the usage of getPosASLW can lead to unwanted results, especially with heavy sea (especially since you seem to check for depths between -83 and -85m).

 

State exactly what you want to do, since there's probably a more convenient way to do it other than spawning and deleting triggers inside a while loop.

 

Cheers

  • Like 1

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

×