Hungry hungry regex matches :) (Typewriter.Play ArgumentOutOfRangeException)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
aguynamededward
Posts: 8
Joined: Sat Aug 26, 2023 1:22 am

Hungry hungry regex matches :) (Typewriter.Play ArgumentOutOfRangeException)

Post by aguynamededward »

Hey Tony -

Was debugging an issue with our game, and noticed we were getting an "ArgumentOutOfRangeException" - basically, we had a string that was coming in 30-40 chars less than it should, when it came time for the typewriter to play.

Basically, a string that started the method like this:

Code: Select all

If you don\'t have enough <sprite=\"StatIcons\" name=enervation> energy (<color=#EE8695>displayed in the bottom left of the screen</color>), then you won\'t be able to play the card.
was finishing like this:

Code: Select all

If you don\'t have enough ), then you won\'t be able to play the card.
Basically, it was starting at the <sprite> tag and removing everything until the close of the <color> tag.

Traced it further, and found the Tools.StripTextMeshProTags was chopping off the extra text, and I traced it down to the sprite regex filter:

By changing this:

Code: Select all

<sprite=.+>
to the less hungry/more lazy:

Code: Select all

<sprite=.+?>
it seemed to remove the error with no problems otherwise.

Don't know if that'll throw other problems later, but I figure you get enough messages with "I have a problem!" that the occasional "I have a solution!" is not out of line. :)

Thanks for all the work you do, you're awesome!
Edward
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hungry hungry regex matches :) (Typewriter.Play ArgumentOutOfRangeException)

Post by Tony Li »

Good catch! I'll make that fix.
Post Reply