0 Favourites

How do I uniformly use expressions to set properties?

  • I'm finding that I often want to set the properties of an instance with an expression. And while some actions allow expressions as input, some do not. Some only allow numbers or only offer an either/or for a boolean. I'm finding this hard to work with in many cases.

    For example, I have a collection of instances that I want to loop through and randomly set their flip property. If I could use an expression, it would be as simple as using a "for each" condition connected to a "set flipped" action of "floor(random(2))". But the "set flipped" action only offers a drop-down selector of flipped or not flipped. And to use that, it seems like I would need a much more complex arrangement.

    Is there any way to simply set it with an expression?

    Failing that, is there a simple way to accomplish the above that I'm missing? (The best I've found is to call a function with the IID and use a global variable to store the random and compare to that to set it.)

    Thanks!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • YES me too! I end up making a function that takes an expression and does that. It would also be nice for doing boolean math that way too like "X=X-(object.mirrored)" or something.

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