Can't compare instance variables?

0 favourites
  • 13 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm trying to compare two boolean values, but for some reason it says I need to create instance variables first. I have, and if I use a single instance variable condition the list shows the items, but when I try to compare two, it says I have to create instance items first. Any ideas?

  • I don't think that is possible to do that.

    As boolean just store true or false I think that you just need to create an condition on your object: is boolean instance variable set? for both, if both are set it means that both have the same value.

  • I'm new to Construct 3, but are you suggesting that construct doesn't support comparing one value against another?

  • I'm new to Construct 3, but are you suggesting that construct doesn't support comparing one value against another?

    No, Im saying that C3 probably not allow to compare a value (string, text, number) to a boolean (flag).

    And that C3 has a condition to compare if the boolean variable flag are true or false.

  • So this is my setup:

    If I were doing this in javascript, i'd have a condition after those two like so:

    if (this.Hovered != this.LastHovered) {
     // Do Stuff
    }
    

    How would I replicate this comparison as a condition?

  • So this is my setup:

    If I were doing this in javascript, i'd have a condition after those two like so:

    > if (this.Hovered != this.LastHovered) {
    // Do Stuff
    }
    

    How would I replicate this comparison as a condition?

    I thought it was an instance variable. Try condition: System -> is boolean set

  • I forgot to remove the variable before taking the screenshot, sorry! I've got it working with the following setup, but I'd prefer to not have to have two chained conditions like this, I'd prefer to be able to say 'if the values are different'.

    Does this make sense?

  • yes but, cant you just set the action on Cursor is over?

  • I could, but this is just the mouse part. I'm also going to support joysticks and I want to be able to set the hover state programmatically so for console the user can press the dpad to change the button thats being hovered over.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see.

    I don't think that you need 2 booleans to compare, or maybe I'm not understanding it correct.

    If you remove "LastHoveredValue", doesn't it work same way?

  • No, without tracking the second variable, the condition gets evaluated every frame. I don't want to do no-op DOM updates every single frame for as that'd be incredibly wasteful. I'm just going to keep it the way I have it and consider it a shortcoming of construct I'll have to work around.

    This is as clean as it's going to get I guess...

  • True but following your screenshot you still are setting the Hovered variable to true/false and calling the function every frame.

    I think that you need to compare LastHoveredValue here, not inside the function.

  • If I were doing this in javascript, i'd have a condition after those two like so:

    if (this.Hovered != this.LastHovered) {

    // Do Stuff

    }

    How would I replicate this comparison as a condition?

    You can use the system condition "evaluate expression" and use variableA=1 & VariableB=1 or any combination of true or false.

    For the boolean state 1 is true & 0 is false.

    **EDIT sorry read to quick. You want Evaluate Expression (A=1 & B=0) | (A=0& B=1) that will give you not equals to for your booleans

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