Forum Discussion

MarkFensom-74e4's avatar
MarkFensom-74e4
Community Member
2 years ago

Variables help

I've simplified my problem to one box and two ovals.

You can see it here.

When you place either oval in the box, the variable BoxOccupied changes to true.

However, when you place both ovals in the box and remove only one, the variable changes to false even though the other oval still occupies the box. How can I change this behaviour to keep the variable true whenever the box is occupied?

Am I missing something obvious? I'd love to hear your solutions.

  • LouiseLindop's avatar
    LouiseLindop
    Community Member

    Hi Mark. It's going to set it to False whenever you remove either Oval because that is what your triggers are telling it to do. I'm not sure what your actual objective is, but I would either use two different variables or a number variable instead. There are a bunch of different ways to do it, but I've modified and used a counter variable and attached. 

  • Hi Louise, thanks for this.

    I need the BoxOccupied variable to control something else when it's true. I can use the number variable zero as false and any number greater than zero as true.

    This is a more straightforward solution than what I had planned.

    I'll test this out on my main project.

    Thanks again.

  • LouiseLindop's avatar
    LouiseLindop
    Community Member

    You could have a trigger that tests when variable changes. That is: Do whatever action you want when counter changes if countern (n being 0, 1 or 2, depending on what you want to do). See attached.