Choose() Question (SOLVED)

Get help using Construct 2

Post » Fri Jan 24, 2014 6:07 am

I would like to create a coin based off whether or not choose() has chosen the '1'. I would like to keep it simple if that's possible.

How can I find out whether or not the '1' was chosen?

To elaborate I only want the coin to spawn above the enemies head if the gold was added. Any ideas? I am stumped! Thank you!

Wolph2014-01-24 08:35:00
Posts: 28
Reputation: 756

Post » Fri Jan 24, 2014 6:20 am

On destroyed > Add 1 To SCORE
             > Set GOLD_ADD to Choose (0,0,0,1)
TriggerOnce > Spawn coin.
            > Add GOLD_ADD to GOLD
            > Set GOLD_ ADD to 0.


Fixed a typo in the 2nd action in "On Destroyed" its GOLD_ADD (like it reads now) instead of GOLD_AAD. Thanks @Mystaszea!

Beginner explanation of the code:

Choose is a function that picks a random number from the options we give it. In this case (0,0,0,1) We dont have a way to know wich number the program will pick, and that was the problem the OP was facing. He wanted to add the result of the Choose function to another value, but only if the result was 1 and there is no place to check wich number the program picked since it doesnt get stored anywhere. So we just add another Variable like GOLD_ADD,that will store the result of the choose function by telling the program to set this variable to the result of Choose like this: "Set GOLD_ADD to Choose (0,0,0,1)"
Once this is done then we can check the result of Choose just by checking our variable, in this case GOLD_ADD like this: GOLD_ADD = 1
Then we can do whatever we want like adding the result of Choose to to the variable GOLD like this: "Add GOLD_ADD to GOLD".

If anyone needed this explanation say thanks to Mystaszea :)

lmchucho2014-01-24 07:28:43
Posts: 133
Reputation: 1,543

Post » Fri Jan 24, 2014 6:31 am

Imchucho....I think you mispelled GOLD_ADD in the declaration phrase...
could you recheck it and EDIT your post to correct if its a mistake.. or it may confuse other people who read this

Perhaps also you could point out that it was a "Variable" that you declared would also steer people who missed what you did there in the right direction

Not everyone understands programming ..but making it clear can help so many people grasp the basics faster..

otherwise that was a perfectly concise answer...nice one mystazsea2014-01-24 06:36:49
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 will save your life.:)
Posts: 318
Reputation: 7,685

Post » Fri Jan 24, 2014 8:32 am

Brilliant! Thank you for the swift reply!
I'm glad it was as easy as a simple Variable, you guys are the greatest!
Posts: 28
Reputation: 756

Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], fearfulelephants and 25 guests