03-15-2014, 12:27 AM
The gsub! method just replaces all instances of .!? with .\005[4] !\005[4] ?\005[4] which is my control code for "stop text rendering for a bit (4 frames)" it works exactly like all the other special codes for gold, hero name, etc. So printed_length in this case would always return 7.
I need to come up with a different solution, possibly capturing the sentence into $2 and using that as the frames to wait.
Edit: 10 minutes of playing around on http://rubular.com/ got me to /(.+?)([?.!][^\n\z"])/
so Works with $2 containing the .!? character and $1 containing the sentence.
I need to come up with a different solution, possibly capturing the sentence into $2 and using that as the frames to wait.
Edit: 10 minutes of playing around on http://rubular.com/ got me to /(.+?)([?.!][^\n\z"])/
so
Code:
@text.gsub!(/(.+?)([?.!][^\n\z"])/) { "#{$1}#{$2}\005[#{$1.length}]" }