How do I check if I have the same value in more than one var

0 favourites
  • 8 posts
From the Asset Store
Footsteps SFX One contains 400 sounds of steps and jumps on different surfaces.
  • I have 10 instances with a local variable (quant) and I need to check if two or more variables have a 10 as value (because it is not allowed) and if at least one variable has a 10 as value (it's a necessary condition).

  • You can pick objects by a variable....

    Pick by comparison - Object.Variable = 10

    Then you can use pickedCount to determine how many were picked and compare it.

    Object.PickedCount is between values 1 & (#number you chose) ---- Or Object.PickedCount = 1 - if there's no upper limit.

    If 0 is picked will return false.

  • Thanks.

    I am doing this:

    Pick all Sprite
    

    Sprite is active (I am checking if the user clicked in each sprite)

    >> Pick Sprite where Sprite.quant = 10

    >>>>Sprite.PickedCount > 1 (to check if exist more than an instance with 10 value in its variable) => action

    >>>>Else => action

    Else => action[/code:3cyi3ss4]

    But it is not working.

  • I changed the script for this:

    Pick all Sprite
    Sprite is active
    Pick all Sprite
    Pick Sprite where Sprite.quant = 10
    Sprite.PickedCount  >= (greater or equal) 1
    Sprite.PickedCount  > 1 => action
    Else => action
    Else => action[/code:3su1hr6i]
    
    The problems are:
    [ul]
    	[li]I cannot confirm if all the sprites are active. I just can check if all the Sprites are not active (e.g. nothing happens If I have one instance activated)[/li]
    	[li]I cannot confirm If none of my instances does not have the value 10, only if has 1 or more.[/li]
    [/ul]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • New Event > Condition > Sprite = active ? (i understand that they all have to be active)

    __Sub event > Condition > System > compare 2 values .. First = Sprite.PickedCount .. = ... Second = Sprite.Count

    _____Sub condition > Sprite > Compare instance variable > ... variable = quant ... equal to ... 10

    __________Sub condition > Condition > System > compare 2 values .. First = Sprite.PickedCount .. > ... 1

    ________________those actions run when there are more then 1 active sprites with quant = 10

    _____Else

    __________those actions run when there are NO active sprites with quant = 10

    __Else

    _____those actions run when not all sprites are active

    Else

    _____Those actions run if there is not one active sprite

  • I tried your script but I am still don't getting the result I want.

    Just one instance may have 10 as value if not, I need to ask the user choose one of them to set as 10.

    I also need to know if the user did not activate all the instances (clicking them). This is the reason that I am checking if all the instances are activated or not.

  • I found the error thanks to your example.

    Thank you.

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