Is it possible to set Boolean variable from expression

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Im trying to set an instance Boolean variable based on an expression, i know i can use the expression itself to get the Boolean value but i don't want to have to keep evaluating the Boolean value each tick when its state only changes during a triggered event. so during the triggered event i want to set the Boolean based on some come condition but the set Boolean drop down is prepopulated with true and false and i cannot set it to an expression is this possible currently.

  • Conditions are set on the left. (i.e when mouse clicked and variablex = 1) [note you can stack the conditions or even have sub conditions/sub events]

    Actions are on the right (i.w set the Boolean true or false)

    i dont think you can set a Boolean by expression in an action (you would do it in a separate condition)

    If you want set the variable directly in the action then use a normal variable, if it is to be a Boolean type just fill it with a 1 or a 0

    then you can evaluate something else to get the return value for the variable in the action.


    sorry i just read what I wrote and I cant even understand it.

    to simplify

    as far as i can see you cant set a Boolean with an expression in an action

    but you could set the conditions then just have another event that checks the conditions and sets the boolean

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ... i don't want to have to keep evaluating the Boolean value each tick

    Yet, that is the way to go.

    Unless you eliminate the use of the Boolean and move the actions that belong to its evaluating condition to the trigger.

    Assuming, that i understand you correct. This not what you wanna do ...

    On collision < a trigger

    .............. set Boolean

    On Boolean

    .............. do stuff

    Then just do this ...

    On collision

    ............ do stuff

  • yeah that works for the simple case, but what if the Boolean is used in more than place? like lets take for example isAiming?

    rightmouse button down => isAiming = true (so this right here isAiming needs to be a more complicated expression) like isAiming = (WeaponType == 1)

    ifAiming => doSomething here

    somewhere else like ...

    if Aiming => play animation?

    i mean i can just use the expression each time, its not too bad, or i can use sub events to get the desired effect, it would be nice to have a system action set boolean by expression or just have set value work on boolean values, but i can deal with it thanks

  • Right mouse button down ?

    Sprite > instance Munition > 12 ?

    _______________ Sprite > Set boolean true

    In the Animations Group

    Sprite > Is boolean instance variable set ?

    _______________ Sprite > set animation

    In some other group

    Sprite > Is boolean instance variable set ?

    _______________ Sprite > do something else

    _______________ UNREFERENCED object > do something

    That sort kinda of situation?

    Dont understand why you would use the expression. The condition is perfect fine ?

    And blazing fast, if not true ... it just skips all the subs and actions.

    There is no way that you can do it faster than this.

    Unless i dont know where you are going with this.

    You (i think) forget two important things.

    1/ That boolean needs to be set false again. Setting that boolean false is not always easy. In this case it is easy.

    On Right mouse released

    _______________ Sprite > Set boolean true

    This is a new event. As you notice.

    2/ You see (i think) that boolean just as something that true/untrue. But it is way more then that.

    Never forget the 'Sprite' that i wrote several times up there.

    The condition 'Sprite > Is boolean instance variable set' PICKS all instances for that Sprite with that boolean = true. Its action work on all picked sprites.

    As long as that picklist is not empty, actions addressing unreferenced objects will work on all instances of that unreferenced object.

    So, if you set a boolean, and use that later to set animations (by instance), the condition also picks the right objects to set the animation to.

    That might sound weird because you talk about an object with only 1 instance. Yet, also that 1 instance needs to be picked. And you better pick it intentional, rather than par hazard.

  • okay i see, so..

    right mouse button down & sprite.ammo > 12 are together in the same condition which sets the boolean there could be an else after to set it to false which should work.


    i'd need to have an extra event but it works well,

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