Jump to content

Recommended Posts

I want to make a ring course to fly through. The ring course will be defined by several markers (ringMARK1_1) and the ring itself has a trigger attached. Each time a ring is cleared I want it to snap to the next position. There is only one ring which moves from marker to marker.

ringCHALLENGE.sqf
 

ringChallenge = [] spawn {

waitUntil {
    ring1==1
    };

hint "Ring Challenge Activated";
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 0;
sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
};

What's the best way to update the ring position in a sequence? Can "select 0;" in the array be called something like "select next"?

Is it better to use IF/WAIT for the next ring?

Am I starting this all wrong?

Share this post


Link to post
Share on other sites

Maybe forEach loop with waitUntil condition?

  • Like 1

Share this post


Link to post
Share on other sites

@Ezcoo,

Thanks.

I have these two pages in front of me: waitUntil and forEach, but I'm not sure how to cycle the current marker.

Let's say hitting the trigger fires the script and that's it. The script has to know which ring marker to select next.

The ring course won't be too long. Seven rings tops. So it would be fine to have each ring defined in a sequence.

Like:
if ring1==1
update ring position

if ring2==1
update ring position

ect.

but then I don't know how to stop the script after each update. The script I have now works like above-- but once the chain is started the ring position updates down the string of markers without the trigger activating (the script runs to completion).

This would work if the script stopped between each ring and waited for the trigger again. Right now the script just plays straight through after triggered.

//challenge 1
ringChallenge = [] spawn {

waitUntil {
    Startflight==1
    };

if (ring1==1) then{
hint "Ring Challenge Activated";
    playergroup = group Player;
    deleteWaypoint [playergroup, 0];
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 0;
sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=1;
    };

if (ring2==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 1;

sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=0;
    ring3=1;
    };

if (ring3==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 2;

sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=0;
    ring3=1;
    };
};

 

Share this post


Link to post
Share on other sites

Lol!

Putting the effects in the opposite order corrects the problem.

this works but the above does not...
 

//challenge 1
ringChallenge = [] spawn {

waitUntil {
    Startflight==1
    };

if (ring3==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 2;

sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=0;
    ring3=1;
    terminate rings;
    };
};

if (ring2==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 1;

sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=0;
    ring3=1;
    terminate rings;
    };


if (ring1==1) then{
hint "Ring Challenge Activated";
    playergroup = group Player;
    deleteWaypoint [playergroup, 0];
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3] select 0;
sleep 1;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=1;
    terminate rings;
    };

It really shouldn't work. It isn't correct. It's not even what I intended to write. Fixing it, closing the waitUntil at the end, instead of after the first script block, actually makes it work less. In that case it skips the final ringMark (it proceeds past it automatically-- the same issue from above.)

So this is the final working version. Complete with black magic to make it work.
I don't know why this works/doesn't work. I wish I did. If somebody wants to explain using the script as an example it will probably help my core-competency and require my asking fewer needless questions of the community.

 

//challenge 1
ringChallenge = [] spawn {

waitUntil {
    Startflight==1
    };

if (ring6==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 5;

sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring6=0;
    ring1=1;
    terminate rings;
    };
}; //this closes the waitUntil which I meant to put at the bottom

if (ring5==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 4;

sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring5=0;
    ring6=1;
    terminate rings;
    };

if (ring4==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 3;

sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring4=0;
    ring5=1;
    terminate rings;
    };

if (ring3==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 2;

sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring3=0;
    ring4=1;
    terminate rings;
    };

if (ring2==1) then{
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 1;

sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=0;
    ring3=1;
hint"";
    terminate rings;
    };


if (ring1==1) then{
hint "Ring Challenge Activated";
    playergroup = group Player;
    deleteWaypoint [playergroup, 0];
currentRING= [ringMARK1_1,ringMARK1_2,ringMARK1_3,ringMARK1_4, ringMARK1_5, ringMark1_6] select 0;
sleep 0.2;
    ["task1",[currentRING,true]] call BIS_fnc_taskSetDestination;
    ringGOAL setpos (getpos currentRING);
    ring2=1;
    ring1=0;
    terminate rings;
    };
//this is where I meant to close the waitUntil but that doesn't work (fires the first script snippet automatically and therefor skips it)

Somebody help me understand why this works when it shouldn't.
 

Share this post


Link to post
Share on other sites

WIth forEach and waitUntil I mean something like this (pseudocode):

 

{
	"show the current ring (_x)"
    "waitUntil the pilot has passed the current ring"
    "hide the current ring"
} forEach rings;

 

  • Like 1

Share this post


Link to post
Share on other sites

@Ezcoo,

Thanks man. No worries. It works well enough.
 

{ "show the current ring (_x)" "waitUntil the pilot has passed the current ring" "hide the current ring" } forEach rings;

There is only one ring (the one to rule them all) which snaps into the next position each time it is cleared. The whole composition is 1 ring, 1 trigger, and as many markers as you want rings to clear.

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  

×