mattshallow's Forum Posts

  • In the image below I want the hawk to swoop from top left of screen towards a worm that has been touched by the player. I then want hawk to end up at other end of screen. The worms are spawned and are moving. I am not sure what behaviour to use: pin, bullet, car physics, path etc...

    Any good examples out there?

  • [quote:3d8jrzzl]Special characters can't be lower or upper case

    For me they are being detected under both. So if I toggle off my Regex expression without the else statements, the special char will be read into both upper and lowercase.

  • Just to clarify, I do have it working using regex search and having the other two events as else statements

    check if special char

    else

    check if lower case

    else

    check if uppercase

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:3ko9lbit]But after that the condition letterText text is "$" worked for me

    Did you toggle off the lowercase and uppercase events below it? Because special characters are considered as lower and uppercase also. If they are off the statement does not work for me.

    [quote:3ko9lbit]You can actually get rid of the txt file and AJAX, just store all letters in a text variable

    That's true. I am just trying to get familiar with construct 2 features. I will eventually have a save and load file so I might need AJAX for that.

  • yeah it is much clearer now. I am at the point now where if it ain't broke don't fix it. Thanks for the explanation!

  • OK, this works.

    RegexSearch(letterText.Text, "", "i")

    removing ^ and $ before and after square brackets while also having the correct boolean check.

  • I spoke too soon. regex search seems to not filter the strings at all. I wonder do you know the particular regex function I should be using for this check?

  • [quote:20ol6kky]A simple regex would work. For example, "^[!@#$%?&*()]$"

    RegexSearch does the job. It is now working

    RegexSearch(letterText.Text, "^[!@#$%?&*()]$", "i")

    I was not too familiar with regex but since you gave me the format for it that made testing much easier. I need to read up more on regex.

    I appreciate all the help guys!

  • [quote:qr1741gp]Are there line breaks or spaces between each token in the file

    Nope. The condition in original screenshot works with other letters in the file. Just not with special chars.

    I tried changing format of file and used trim() to make sure no extra chars in the text but still no luck. I think regex is the way to go if I figure that out but this issue might pop up again so want to resolve that first.

    Attach is the capx.

    https://drive.google.com/open?id=1ZSuWmbdBYQGwgfM5Nbl9g4ioLBIBJ8nl

    Thanks again for your help!

  • No there is nothing else there. I have a text file of letters with special chars and using AJAX to read them in. I am then populating an array. The letter comparison check works fine but the special chars do not. The original piece of code I have in screen shot still does not work.

    Maybe when the char is converted from .txt the formatting for special chars is altered. Or possibly when read into the array but I can see the values in the debugger. Below is the code reading file and placing in array. I am actually randomly selecting letters from array to place individually on object.

  • If it does I will hit myself! I'll check now....

  • I have a bit of a workaround now:

    System->left(letterText.Text, 0) = "$"

    Checks the left most character and I can compare. I'll see if I can get it to check all special chars rather than having to multiple checks for each character.

  • [quote:2nymnz3y]Do you need to check if the text contains "$", or if it exactly is "$"?

    I need to check if the text is "$". To be more precise I need to check if the text is any special character. I was looking a regex but I am not sure which regex will suite my needs.

    So to be clear. I have a piece of text that can hold one special character. I need to do a check to see if that text is one of the special characters so I can add to a variable.

  • I tried that also and does not work. I did discover that the special characters are recognised as both upper and lower case. Don't know if that means anything though.

  • I am trying the following which should work. The text box contains a "$" string. I have tried a few other special characters and it also does not work. It works with ordinary characters though.