Set bool from expression or variable

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Is it possible to set a bool from an expression or from another variable, when I go set a bool I get a drop down with true and false. How can I make that bool dependent on something else or pass in a string "true" or "false" and just cast it, do i have to use an int? 0 1 to dynamically at that value?

  • It's not clear why you find true/false options unsuitable for a bool, but yes you can say if a variable string = the literal string "true" or "false", or you can say if a variable int = 0 or 1.

  • true and false is suitable, but if I wanted the result of that bool to be dynamic based some other conditions I can't do it in line the action for set bool takes a hard-coded value for true and false... In order to do what I want I can use a function with sub events and based on those sub events set the bool... It just seems like alot extra work for something as trivial as setting a value.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Piranha, I know what you mean about working with boolean variables, where you can't set the value with an expression, which is different from string and number types. Unless I'm missing some technique? That seems odd, but must be a design choice in Construct, maybe to reduce developer errors.

    I use booleans like you describe, toggling them from within a function, for example.

  • If you look in Construct you cannot set a local or global bool, there is only an instance variable bool which applies to a particular object. If you are trying to pass a general bool value through a function or return a true/false then there are other ways to do it. Using the bool in conditions or actions should be enough, if you are trying to do something specifically then post exactly what you are trying to do and I can assist.

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