Comparing Two text object's text doesn't work

0 favourites
  • 2 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I've been trying to fix this for hours, and I still cannot figure out why it isn't working.

    What i'm doing is I have 2 Text objects and AJAX

    One of the Text Objects is being given a value from a web address ("1.0.0" is the value)

    The other one is being sent the ProjectVersion ("1.0.0" and I change it to test the system)

    I'm comparing the ProjectVersion (InstalledVersion.text) to the AJAXValue (CurrentVersion.text)

    (yes, I've also tried CompareText on InstalledVersion and tested for CurrentVersion.text, same outcome)

    If those are the same, two objects go invisible

    If those are different, the same to objects go visible

    However... they never go invisible, even if I change the game's versions, it doesn't change and I don't understand why.

    Can someone explain why this isn't working?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey RadDevVan101,

    So if the two objects never go invisible, then it seems like somehow the two values ("Web" value & "Project" value) are never considered to be the same, even when it looks like they should be.

    From here on I'll refer to the two objects as the "Sprite", to make things simpler.

    I'm assuming that somewhere in your event's there's an event that looks something like:

    If Web == Project: Then Set Sprite Invisible.

    Firstly, as a test, I would try changing that event's condition to always be true (i.e. Delete just the condition, or test for 1 == 1 or something) to make sure that the event is even capable of turning the Sprite invisible at all.

    When you run the test described above, the Sprite should turn invisible as soon as that event runs, regardless of the Web and Project values.

    If that works, and the Sprite becomes invisable, then you know that the event does get executed, but the Web == Project test is always false for some reason. If so, be sure to undo the changes to return the event to it's original form. On the other hand, If the Sprite does not turn invisible, it may mean the event is never actually running for some reason.

    If the event is running, then the question is, "Why does Construct insist that the values never match?"

    There are a few reasons the values might not match.

    • There is a space before or after one of the version numbers, e.g. "1.0.0_"
    • One of the values is being treated like a numeric data type (integer or float) at some point in your events, or in an expression. That would cause "1.0.0" to become "1", which will not match "1.0.0" if you compare strings.
    • You might be storing one of the values in a Construct2 variable, that is set to "number" instead of "text".

    Finally, you can try printing out the values to an other text object when the event runs so you can see exactly what the values are at the instant they are being compared. To do this, add another text object to your layout, (e.g. named "debugText"). Then in the Web == Project event, add an action print the Web and Project values to the debugText object.

    Hope that helps.

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