Hey guys! It’s me, the D man, and i’m here to show you guys uhhh
How to make a Typewriter effect like in Undertale or some RPG game and stuff using strings and variables!!
Now uhhhh read below
Blocks that we'll be using
- Set Value
- Wait Block
- Set Text
- Increase by
- Start sound
- Check once if
Making the thing itself
First, make a text object. You could name it anything and place it anywhere.
Then, we code!
To start things off, let’s make 2 variables that we’ll be using. You could name them both anything, just don’t forget them! I’ll be calling them “Text” and “TextEnd” for now.
Alright, now add a “when game starts rule”. Then, add:
Set (Text) to (Your text here) <---- The Text value is one of the variables we created earlier. It will be used as the text that will be typed into. Don’t get it mixed up with the other text value!
Once we finished doing that, add a “when game is playing” rule. This is where the typewriting thing effect be coded into.
Now, add the following blocks into the rule:
Wait seconds(0.05) <—This is the delay between every letter. You could change it to anything you want.
Set text to (characters in (Text) between (0) and (TextEnd)) <—The “TextEnd” is the second value that we created earlier. The “Text” is the value that we used back in the “game starts” rule. Don’t get it mixed up with the other text value!
Check once if ((TextEnd) < (length(Text))) Increase (TextEnd) by 1 Start Sound (mouse click) wait (0) End
Just follow that because i’m a bit lazy explaining it. Just don’t get the Text value mixed up with the other premade Text value.
Oh, and also the Start Sound block is optional.
Anyway, there we go! Now if we test it, it should work. I’ll probably be working on a YT video soon.
If it doesn’t work, just ask here and ill probably help or something.
Adding more text dialog
This one is a bit more simple. Go back to the When game starts rule, and add a wait() block into it.
Try putting it to around 4-5 seconds so it doesn’t cut to the other text before the current text finishes. If your text is quite long, try increasing it.
After the wait block, add
Set (TextEnd) to 0
This is very important. If you don’t add that, it might break.
Anyway, after that, go ahead and add
Set (Text) to (your text here)
Again, don’t get the Text value mixed up with the premade Text value.
Now that’s finished! If you want to add more (again), just repeat this process.
that took a while to type uh if theres any problems ask in this topic ok byeeee
Oh, one thing; it might break if there’s a notification that pops up because for some reason
Hopscotch freezes a bit when that happens.
Alright bye yall
(im bad at explaining lol)