Choose() Question (SOLVED)

0 favourites
  • 4 posts
  • 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!

    <img src="http://i.imgur.com/uUsCryL.jpg" border="0" />

  • On destroyed > Add 1 To SCORE

                 > Set GOLD_ADD to Choose (0,0,0,1)

    GOLD_ADD = 1

    TriggerOnce > Spawn coin.

                > Add GOLD_ADD to GOLD

                > Set GOLD_ ADD to 0.

    Edit:

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

    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 :)

  • 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 <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Brilliant! Thank you for the swift reply!

    I'm glad it was as easy as a simple Variable, you guys are the greatest!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)