How do I Evaluate that none were picked?

0 favourites
  • 11 posts
From the Asset Store
Pick Up Items Sounds
$3 USD
50% off
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Having trouble figuring out how to pick objects based on a certain type, but then do something when there were none picked.

    This doesn't work.

  • Should work that looks correct. Use an action to set a variable to pickedcount to find out what it's finding.

  • I know this works...

    but I'm just wondering how to reverse the logic so that the event in which there are none then a set of actions happen - but not in an ELSE statement.

  • The event you posted originally is the event in which there are none picked so you already have it. If it didn't work as expected then it means it found at least one, so set a variable or text to pickedcount to see what value it's finding, it can't be 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I believe PickedCount=0 does not work by design as PickedCount only returns a value when there are objects picked.

    Else is the only way.

  • its just awkward looking...

    here I'm saying if there are no drone owned by the player's ship, then spawn one. There has to be a more logical way to do this.

    its somewhat offensive as a programmer to look at this!

  • The reason the pick all doesn't return 0 is because the pick event doesn't actually even run if there are no instances.

    You can use the inverted comparison though to avoid the else.

    Of course that still only works if there drone instances of some sort.

  • its just awkward looking...

    I use "Pick... Else" method all the time. Yes, it looks awkward, but it's the easiest way to do this.

  • calminthenight oh that's interesting! I actually like that...

    dop2000 good to know, it's just feels very fake or like it exposed something that the engine never intended to do. Seems like if there was they would have made a special case Event for it. Like: 'None Picked' or 'Pick doesn't exist'

  • You could also do it with a local variable, but it’ll still be two events.

    Local number any=0
    Sprite: x=33
    —— set any to 1
    Any=0
    ——do something

    The else one isn’t bad. It lines up pretty good with the logic of picking.

    The main rough spot with the picking system is the top level event picking of newly created objects.

  • The main rough spot with the picking system is the top level event picking of newly created objects.

    right, there would have to be a special event similar to "Once While True" or something that would run if no objects were picked in an evaluation. But that would probably break something!

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