How do I change over lapping answer? [SOLVED]

  • Hey.

    So in my game, there is a question and 5 answers. A, B,C,D,E.

    The correct answer is C and E

    so I did coding when C and E checked to add 1 to Correct.

    Then another coding B C and E checked to add 1 to wrong.

    Wrong and Correct are variables.

    And if Correct = 1 show seed (a sprite)

    And if Wrong = 1 Show X (a sprite)

    But when I tried it I checked B, C, and E and it added 1 to Correct instead of Wrong.

    I think this is because of The C and E from the correct answer overlapped with the C and E from the wrong answer, which caused some looping in the code. How can I change this? Attached are the images of my coding. Thanks.

  • As far as I understand in any case scenario, if B is checked, the answer is wrong.

    If that is true, then in the second part just check B.

  • As far as I understand in any case scenario, if B is checked, the answer is wrong.

    If that is true, then in the second part just check B.

    Yes, but I will be exporting this game and others will play through which I don't have control. If they do B C and E what do I do

  • Try this:

    C checked 
    and E checked
    and Submit checked
    	B checked -> wrong
    	else -> correct
    
  • Try this:

    > C checked 
    and E checked
    and Submit checked
    	B checked -> wrong
    	else -> correct
    

    Thanks, it worked!

  • Try this:

    > C checked 
    and E checked
    and Submit checked
    	B checked -> wrong
    	else -> correct
    

    I tried this by doing

    > C checked 
    and E checked
    and Submit checked
    	B checked
    and D checked
    and E checked -> wrong
    	else -> correct
    

    It didn't work.

    Also else cannot be used as a sub-event

    I also tried

    > 	B checked
    

    and D checked

    /code]

    and

    > 	B checked
    

    and E checked

    /code]

    and so on

    None of them worked

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you post a screenshot of events? Or better yet - your project file.

  • Due to some, uh, restrictions, I cannot post my project file.

    But I can give you my screenshots😊

    Here's the code

    and

    the else

  • Where is that "else"? I can't make sense of your code..

    If only one combination of checkboxes can be correct, all you need to do is this:

    Submit is clicked
    
    	.... is checked 
    	.... is checked (the winning combination)
    	.... is checked
    		Add 1 to Correct
    	Else 
    		Add 1 to Wrong
    

    Note, I recommend changing Submit to a button, this way you will not have to use "Trigger once" (which can cause different problems in this code).

  • Where is that "else"? I can't make sense of your code..

    If only one combination of checkboxes can be correct, all you need to do is this:

    > Submit is clicked
    
    	.... is checked 
    	.... is checked (the winning combination)
    	.... is checked
    		Add 1 to Correct
    	Else 
    		Add 1 to Wrong
    

    Note, I recommend changing Submit to a button, this way you will not have to use "Trigger once" (which can cause different problems in this code).

    yes but, the event 'else' does not work if there is a triggered event.

    such as 'Submit is clicked' above it

  • Look closely at my code. "Submit is clicked" is the parent event. It has a sub-event where you compare multiple checkboxes. Else condition is under that sub-event, on the same level.

  • Look closely at my code. "Submit is clicked" is the parent event. It has a sub-event where you compare multiple checkboxes. Else condition is under that sub-event, on the same level.

    I though else cannot be a sub-event

  • Look closely at my code. "Submit is clicked" is the parent event. It has a sub-event where you compare multiple checkboxes. Else condition is under that sub-event, on the same level.

    Oh got it. Let me test it out

  • Look closely at my code. "Submit is clicked" is the parent event. It has a sub-event where you compare multiple checkboxes. Else condition is under that sub-event, on the same level.

    Ok but Else cannot have a triggered condition in its same event

    Submit is clicked
    .... is checked 
     	.... is checked (the winning combination)
    	.... is checked
     		Add 1 to Correct
     	Else 
     Submit is clicked
    		Add 1 to Wrong
    

    The code doesn't work because submit is a button, and if I don't that then when the game begins it automatically adds 1 to wrong because nothing is checked which comes under 'Else'

  • Look closely at my code. "Submit is clicked" is the parent event. It has a sub-event where you compare multiple checkboxes. Else condition is under that sub-event, on the same level.

    It created the same problem as before. When I checked A and B etc. it worked. But when

    i pressed A C and E it didn't work and added 2 to correct instead of none. Attached is my code

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