Jump to content

Recommended Posts

Hi there. I'm having an issue with setting a trigger to activate when all items are collected, but I'm having trouble properly formatting an "and" statement.

When the item is collected, the deleteVehicle command is used to remove the item from the world space, so I have a statement that basically says "When money 1 AND money2 AND money3 AND money4 AND money5 are not alive, then activate the settaskstate module.

 

The variables for the money items are all set and have a script to delete each item on pickup.

 

What is the proper way to format this statement?

 

I've tried many variants, but this is my current code currently in the init field of the trigger.
 

(!alive money1) && (!alive money2) && (!alive money3) && (!alive money4) && (!alive money5) 

 

Share this post


Link to post
Share on other sites

This statement returns true once all money1-5 are deleted.

Make sure you got no spelling errors and the trigger is set to anybody.

Should usually work.

 

Cheers

Share this post


Link to post
Share on other sites
10 minutes ago, Grumpy Old Man said:

This statement returns true once all money1-5 are deleted.

Make sure you got no spelling errors and the trigger is set to anybody.

Should usually work.

Unfortunately, I've tried this. It works with every individual item in a simple statement, but the and statements don't seem to work.

Share this post


Link to post
Share on other sites

Solved. It won't let me edit the post, but I've solved this by unlinking the group performing the the task from that trigger and using this string.

 

Quote

!alive money1 && !alive money2 && !alive money3 && !alive money4 && !alive money5;

 

Share this post


Link to post
Share on other sites

I know that you have solved it but, just wanted to say that you can also do something like:

if ((({alive _x} count [money1, money2, money3, money4, money5]) isEqualTo 5)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

Probably other ways as well but yeah. 5 means, all 5 elements (money 1 to 5) in the array is alive. If you change 5 to say 2, then only two of the elements would need to be true.

  • Like 1

Share this post


Link to post
Share on other sites
17 minutes ago, HazJ said:

I know that you have solved it but, just wanted to say that you can also do something like:


if ((({alive _x} count [money1, money2, money3, money4, money5]) isEqualTo 5)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

Probably other ways as well but yeah. 5 means, all 5 elements (money 1 to 5) in the array is alive. If you change 5 to say 2, then only two of the elements would need to be true.

 

Definitely helpful. I can place many items and only require a certain amount to continue. That's cool. I'll remember this.

Share this post


Link to post
Share on other sites

No problem, you can also use > and < operators as well.

// 2 or less elements are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) < 3)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

// 3 elements or more are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) > 2)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

You can combine these with = as well like so:

// 3 or less elements are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) <= 3)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

 

Share this post


Link to post
Share on other sites
4 minutes ago, HazJ said:

No problem, you can also use > and < operators as well.


// 2 or less elements are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) < 3)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

// 3 elements or more are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) > 2)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

You can combine these with = as well like so:


// 3 or less elements are true
if ((({alive _x} count [money1, money2, money3, money4, money5]) <= 3)) then
{
	hintSilent "True!";
} else
{
	hintSilent "False!";
};

 

 

Actually, this is genius! I can use this to display helpful tooltips as well. If I set it to keep detecting how many are left and  set it up to tell me how many out of the total are collected, I can use that as encouragement to locate the rest. I really appreciate your time. :D

  • Like 1
  • Thanks 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

×