Problem to compare words between variables

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I don't find any error but the comparison between the variable (currentWord) and the variable (player.word) or with the spritefont's text (wordField) is giving error when the right word is typed. Some help, please. Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By error, you mean it returns "Wrong"? Or if it's an error please give us an error message.

    Try str(wordField.Text) to ensure that the data is string. Another approach is to output the data in textboxes to see what's wrong with the data. I always make a layout with some textboxes for testing.

  • Hi janlindso

    Yes, the script runs the "else" actions. I have tried to force the string and I've used text object instead variables and sprite font object. The text object loaded the data correctly but when I compared the text with variables, the sprite font or with another text object, the result is the same. I really don't understand why this condition doesn't stay true.

  • You also tried str where you get the values from the array to force as a string? Did you tried replacing the two to test with a string?

    For example:

    currentWord = "The word to test"


    "The word to test" = wordField.Text

    This way you'll find out if it's the textfield or the array, but I would guess the array that is causing it.

  • If you have a situation like this:



    but ..


    (word ?word)

    you probably comparing "word " and "word"

    (Var=word& space)

    set Var to trim(Var)


    Return src with all whitespace (spaces, tabs etc.) removed from the beginning and end of the string..

    if not.... upload a capx

  • janlindso

    I've tried to force str in several ways but not worked. Thanks anyway.


    Great! Trim worked very well. Thanks for helping me again, korbaach.

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