Jump to content
warbirdguy1

createTrigger on trigger activation?

Recommended Posts

I am working on challenging myself to learn more about using the SQF side of editing over relying on the clean UI of the EDEN editor.  Here is what I got so far in my init.sqf.

 

Player spawns on VR terrain.  Is asked to run to a VR arrow.  Once the player arrives there at arrow_1/trigger_1 I would like a new trigger to be created.

 

disableUserInput true;
player enableSimulation false;
arrow_1 hideObject true;
arrow_2 hideObject true;

hint "You do not have control at this time.";

sleep 5;

systemChat "Hello and welcome to Sean Cole's mission creation demonstration.";
sleep 3;
systemChat "Lets get started, walk over to the blue arrow.";
hint "You have control.";
player enableSimulation true;
disableUserInput false;
arrow_1 hideObject false;

    trigger_1 = createTrigger ["EmptyDetector", getPos arrow_1];
    trigger_1 setTriggerArea [5, 5, 0, false];
    trigger_1 setTriggerActivation ["WEST", "PRESENT", true];
    trigger_1 setTriggerStatements ["this", "hint 'Good, now lets move to the Red Arrow.'", ""];

 

Here is the where my problems start.

 

if (triggerActivated trigger_1) then {
    arrow_2 hideObject false;
    trigger_2 = createTrigger ["EmptyDetector", getPos arrow_2];
    trigger_2 setTriggerArea [5, 5, 0, false];
    trigger_2 setTriggerActivation ["WEST", "PRESENT", true];
    trigger_2 setTriggerStatements ["this", "hint 'Great, move to the smoke and await the Hummingbird.'", ""];
};

 

I assumed this was the correct next set of statements but it does not seem to be working.  Do you have any good references or can explain to me what I am doing wrong and how to correct it?

 

Thanks in advanced.  Being relatively new to this I sometimes and not sure what the right questions are to ask and have difficulty finding the answers.

Share this post


Link to post
Share on other sites

First of all, you must be under a scheduled scope. I means your script has sleep commands. Init.sqf is fine but not every script. So I added a spawn command for any case.

 

Then, you're checking the trigger_1 activation, on the fly, before your player activate it! The condition returns false.

Make a waitUntil instead:

 

0 = [] spawn {
  disableUserInput true;
  player enableSimulation false;
  arrow_1 hideObject true;
  arrow_2 hideObject true;
  hint "You do not have control at this time.";
  sleep 5;
  systemChat "Hello and welcome to Sean Cole's mission creation demonstration.";
  sleep 3;
  systemChat "Lets get started, walk over to the blue arrow.";
  hint "You have control.";
  player enableSimulation true;
  disableUserInput false;
  arrow_1 hideObject false;
  trigger_1 = createTrigger ["EmptyDetector", getPos arrow_1];
  trigger_1 setTriggerArea [5, 5, 0, false];
  trigger_1 setTriggerActivation ["WEST", "PRESENT", true];
  trigger_1 setTriggerStatements ["this", "hint 'Good, now lets move to the Red Arrow.'", ""];
  
  waitUntil {sleep 1; triggerActivated trigger_1};
  arrow_2 hideObject false;
  trigger_2 = createTrigger ["EmptyDetector", getPos arrow_2];
  trigger_2 setTriggerArea [5, 5, 0, false];
  trigger_2 setTriggerActivation ["WEST", "PRESENT", true];
  trigger_2 setTriggerStatements ["this", "hint 'Great, move to the smoke and await the Hummingbird.'", ""];
};


 

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

×