Comparing Two text object's text doesn't work

Get help using Construct 2

Post » Thu Feb 25, 2016 10:42 pm

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?
B
4
S
1
Posts: 3
Reputation: 356

Post » Fri Feb 26, 2016 3:27 am

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.
B
26
S
17
G
8
Posts: 323
Reputation: 6,021


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, NN81, plinkie, TsubaRu and 10 guests