playMaker

Author Topic: String Typewriter  (Read 8806 times)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
String Typewriter
« on: December 01, 2014, 03:15:55 PM »
    Now you can type fancy text out like the old school games used to without all the trouble it used to be!

    Jean helped me start this one out.. There was a base script on the Unity Wiki called AutoType, but it didn't really fit in the Playmaker action space with its Iterator so we circumvented it.

    Recommened to download via
Ecosystem, but the .cs is attached below as well.

Git Link
Download the .cs file


r5:
  • Feature: Rich Text Support!.. Standard <color><b><i><size> plus <p=[float]> and <s=[float]>.
  • ....Limitations:
  • Cannot use more than one type of modifier at a time. This means you can't have <b><i>text</i></b>, you can only have <b> or <i> to modify a block of text, but you could use any number of them individually anywhere in the string. Just not together (yet).
  • Feature: Special mid-sentence pause and mid-sentence speed change.
  • ....Usage/examples:
  • " Hi Steve.<p=1.8> So.. Um, how are you? "
... <p=1.8> Will produce a pause of 1.8 seconds mid-sentence.
  • " Uhhhh yeaaaah the BBQ at Dekkers is <s=0.01>soamazingomgwtfbbq i need moar nao lol lets go. "
... <s=0.01> Will produce a speed change to a very fast rate, mid-sentence.
  • Known bug: You might notice formatting can get displayed in the text while in the Editor, but it should clear and format correctly at Runtime. This is because the Editor does not recogize the special <s=[float]> and <p=[float]> (speed/pause) blocks and they are physically removed from the string while its being built at Runtime.
  • Known Bug: Using <s=[float]> or <p=[float]> and transitioning states before the action is finished will not cleanup the tags.
  • Bugfix: Lots of small adjustments were made all over the code. It shouldn't affect your existing action definitions but backup before updating anyway just in case
  • Please report any issues related to these features along with the string you're typing.


r4:
  • Bugfix: Last letter was truncated if firing the finished event from the action. String is now compared to the target rather than reading the index value and the Update loop is gated by the finished conditions to avoid out of index errors.

r3:
  • Bugfix: Failed on an index error when looping through states.

r2:
  • Punctuation works now. Use the multiplier to define how much longer it waits in addition to the standard pause.
  • Formatting punctuation is a bit outside normal grammer, rather than punctuating explicitly on each mark or ellipsis it will instead see if the next character is a punctuation mark and if so, not pause for punctuation. This lets you string together question marks combined with exclamations and stuff without a punctuation pause at each one - only the last one. See the new GIF below.

r1:
  • You need a base string for reference and it will type it out from the base string into any target string variable you want (even the original base variable if you prefer, its uncorrupted if you choose to do this.)
  • You can throttle the speed at which it sprays letters into the string with a float variable.
  • You can choose Realtime or not, so it can work with your pause menu's that operate during timeScale=0, if you prefer.
  • If your state is interrupted, the result string is immediately filled on exiting the state so your strings are not corrupted.
  • You have the option add sounds on every key (choose an Audio Source and an AudioClip), and an additional option to skip playing the sound on Spaces.


Let me know if you have any problems or feature requests.

Animated GIF below![/list]
« Last Edit: January 07, 2015, 06:23:37 PM by Lane »

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: String Typewriter
« Reply #1 on: December 01, 2014, 05:45:26 PM »
Nice!  :) Thank you Lane!
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: String Typewriter
« Reply #2 on: December 01, 2014, 10:00:20 PM »
Hi,

 it's compatible with 3.x :)

 Bye,

Jean

marcos

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 199
    • View Profile
Re: String Typewriter
« Reply #3 on: December 01, 2014, 10:53:00 PM »
This is cool! Thank you!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: String Typewriter
« Reply #4 on: December 02, 2014, 12:41:41 PM »
Updated with Punctuation features.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: String Typewriter
« Reply #5 on: December 03, 2014, 07:34:46 AM »
r3: bugfix, error when looping back into an original state. out of index.

Sly

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: String Typewriter
« Reply #6 on: December 03, 2014, 10:20:07 AM »
Wow, it's an impressive action!
Thanks guyz!

terri

  • Sr. Member
  • ****
  • Posts: 349
    • View Profile
    • terrivellmann.tumblr.com
Re: String Typewriter
« Reply #7 on: December 03, 2014, 10:54:28 AM »
Awesome, thanks!

fish

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: String Typewriter
« Reply #8 on: December 21, 2014, 07:38:06 PM »
It looks like the last letter isn't written if you use the finished event.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: String Typewriter
« Reply #9 on: December 22, 2014, 02:50:01 PM »
It looks like the last letter isn't written if you use the finished event.

Found it... Changed things up to process and finish under more controlled circumstances. Updated on this Thread and Ecosystem.

Should be fixed now, let me know.

fish

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: String Typewriter
« Reply #10 on: December 22, 2014, 05:29:22 PM »
Yup, problem solved! I haven't posted much but I was watching this thread. Thanks for the PM though!

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: String Typewriter
« Reply #11 on: January 05, 2015, 12:12:44 PM »
Following this post: http://hutonggames.com/playmakerforum/index.php?topic=9118.0

I *suggest* that we could load multiple bitmap font textures (textures with everything placed in a pre-determined order, like this: https://crimild.files.wordpress.com/2013/08/lucidagrande.jpg), get the corresponding character from the texture and bake it to another texture. This way we could have characters with different colors and fonts on each texture map. Recognize tags to change the bitmap font texture before displaying it on screen (to avoid displaying the tags before it gets formatted while blitting). Choose the speed of the blit and how many characters are blitted on each time.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: String Typewriter
« Reply #12 on: January 05, 2015, 01:02:07 PM »
String Typewriter will output a string, one character at a time, at a defined time interval. There is no need for this action to extrapolate an alphabet atlas from an image or convert anything at all. You should use String Typewriter to construct the string over time and simply feed that into a GUI Text or UI Text where you have already setup the font.

Blitting in this context is an archaic method used to display text on old consoles like Atari because there were no better methods available like the one we're using here.

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: String Typewriter
« Reply #13 on: January 05, 2015, 02:19:33 PM »
I made one string typewritter and had the same problem with tags even the html tags for rich text format. The tag is drawn while typewritting and them gets formatted after the closing tag just like the problem occuring with the string typewritter action. I've googled but couldn't find anything about typewritting and rich text format or how to cache it. I tried this too:

Used this tag "<@>" to change the font color to red and them replace the tag with an empty space. This works almost fine because everything that was written before gets red too and I just want to change the color of the words inside the tag, not before. So until now the arcaic text blitting appears to offer better control over the text formatting than the better method available today.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: String Typewriter
« Reply #14 on: January 05, 2015, 03:57:49 PM »
I made one string typewritter and had the same problem with tags even the html tags for rich text format. The tag is drawn while typewritting and them gets formatted after the closing tag just like the problem occuring with the string typewritter action. I've googled but couldn't find anything about typewritting and rich text format or how to cache it.

This is a known issue, since the current version doesn't support Rich Text..

Quote
So until now the arcaic text blitting appears to offer better control over the text formatting than the better method available today.

Well then its a good thing I sat down and updated the action to support Rich Text this morning so we don't have to regress 20 years. ;)

There are couple of limitations with the latest code, but I think they can be iterated out over time and the support as it stands should be enough for basic formatting uses. I'll post more in a few hours. Currently adding the pausing and speeding up formatting codes and cleanup so you can control the Action variables from inside the string.