How do I only compare a certain part of a text object?

  • Hi guys. I want to make a game which utilises live time. On different dates, different events should happen. I already have a text object where the current day/month/year/etc is displayed. In this situation, I decided to use the "compare text" event in order to check the current month and day while ignoring the rest of the date/time.

    In other words, if the current date is "Tue Dec 18 2018", then which event will recognise "Dec 18" while ignoring "Tue, 2018". This means that the event is only based on "Dec 18" and not on the rest of the information.

    I could not figure out how to do this and hope someone can help me.

  • Hi guys. I want to make a game which utilises live time. On different dates, different events should happen. I already have a text object where the current day/month/year/etc is displayed. In this situation, I decided to use the "compare text" event in order to check the current month and day while ignoring the rest of the date/time.

    In other words, if the current date is "Tue Dec 18 2018", then which event will recognise "Dec 18" while ignoring "Tue, 2018". This means that the event is only based on "Dec 18" and not on the rest of the information.

    I could not figure out how to do this and hope someone can help me.

    One way is to compare with Regex.

    This method compares your text object and puts it into two global variables, which can be accessed for later use.

    Edit

    Actually you could change the first match to RegexMatchAt(Text.Text,"[a-zA-Z]+\b","g",1)

    Which would recognise the second word

  • Thanks for your reply. I unfortunately don't have Construct 3 but 2 instead. I couldn't find a global string option for the variable. Do you know how I could find it? or is there another option?

    Many thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your reply. I unfortunately don't have Construct 3 but 2 instead. I couldn't find a global string option for the variable. Do you know how I could find it? or is there another option?

    Many thanks.

    Here is the capx.

    Here is the link to the capx

    Cheers

  • Thanks! That solved my whole problem.

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