Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » "Scratch way" to show text on the screen
- josh3450
-
Scratcher
5 posts
"Scratch way" to show text on the screen
Hello,
Forgive me if this is already answer somewhere else. I just started learning Scratch a couple of days ago and I was wondering what should be the proper way to show strings of text on the screen? Since Scratch is basically a GUI language I assume that we could create a sprite with the text as different costumes and use hide/show in order to present the desire text on the screen. Is that right? Any other alternative?
Thank you.
–
A Grandpa learning Scratch to teach his granddaughter.
Forgive me if this is already answer somewhere else. I just started learning Scratch a couple of days ago and I was wondering what should be the proper way to show strings of text on the screen? Since Scratch is basically a GUI language I assume that we could create a sprite with the text as different costumes and use hide/show in order to present the desire text on the screen. Is that right? Any other alternative?
Thank you.
–
A Grandpa learning Scratch to teach his granddaughter.
- Za-Chary
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
What you described is one way. If all you need is to show text on a screen without any formatting preferences, a couple of other simpler ways is to use either this block:
Or you could use variables:
For the method involving variables, you'll want to click a checkmark box next to the
block in the Scratch editor. This will show the variable on the Stage. By double-clicking the variable on the Stage, you can change its layout between “normal”, “large”, and “slider”. The “large” layout is one way to display text on the screen.
There is no “proper” way to show text on a screen, but there are many ways to do it. It's just up to you on how you want it to look.
Does this help?
say [Hello!] for (2) secs
Or you could use variables:
set [my variable v] to [Hello!]
For the method involving variables, you'll want to click a checkmark box next to the
(my variable)
block in the Scratch editor. This will show the variable on the Stage. By double-clicking the variable on the Stage, you can change its layout between “normal”, “large”, and “slider”. The “large” layout is one way to display text on the screen.
There is no “proper” way to show text on a screen, but there are many ways to do it. It's just up to you on how you want it to look.
Does this help?
- supernavo
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
There isn't really an alternative. Well, unless you're OK with it being UGLY… In Scratch, you can basically create a “Text Engine,” or use some other people made. Basically, make a costume for every character you want. Also, preferably also make an “error” character. Then, do something like this.
Here's how I like to do it:
Here's how I like to do it:
when flag clickedThen I put render text in a forever loop.
hide
define render text (text) at x: (x) y: (y)
go to x: (x) y: (y)
set [digit v] to [1]
repeat (length of (text))
switch costume to [Error v]
switch costume to (letter (digit) of (text))
create clone of [myself v]
change [digit v] by [1]
end
when I start as a clone
show
wait (0) secs
delete this clone
when gf clickedI got ninja'd oof. Yeah if you're ok with an uglier simpler solution use Za-Chary's solution. Most people are fine with a variable readout, even with that ugly orange backround.
forevah{
render text (join [some variable is ] (some variable))::custom
}@loopArrow::control cap
Last edited by supernavo (Dec. 15, 2022 19:58:46)
- josh3450
-
Scratcher
5 posts
"Scratch way" to show text on the screen
What you described is one way. If all you need is to show text on a screen without any formatting preferences, a couple of other simpler ways is to use either this block:say [Hello!] for (2) secs
Or you could use variables:set [my variable v] to [Hello!]
For the method involving variables, you'll want to click a checkmark box next to the(my variable)
block in the Scratch editor. This will show the variable on the Stage. By double-clicking the variable on the Stage, you can change its layout between “normal”, “large”, and “slider”. The “large” layout is one way to display text on the screen.
There is no “proper” way to show text on a screen, but there are many ways to do it. It's just up to you on how you want it to look.
Does this help?
Of course it helps and thanks for the quick reply. A couple of observations if I may:
The first solution will not allow a text to say on the screen since it is using the for amount of time block, right?
The second one is good but you have to create a variable, correct? It looks like a waste to me, also I think there is no way to get rid of the surrounding box, right?
Again, I'm just learning by comparison with other computer languages I know.
Thanks again.
- josh3450
-
Scratcher
5 posts
"Scratch way" to show text on the screen
There isn't really an alternative. Well, unless you're OK with it being UGLY… In Scratch, you can basically create a “Text Engine,” or use some other people made. Basically, make a costume for every character you want. Also, preferably also make an “error” character. Then, do something like this.
Here's how I like to do it:when flag clickedThen I put render text in a forever loop.
hide
define render text (text) at x: (x) y: (y)
go to x: (x) y: (y)
set [digit v] to [1]
repeat (length of (text))
switch costume to [Error v]
switch costume to (letter (digit) of (text))
create clone of [myself v]
change [digit v] by [1]
end
when I start as a clone
show
wait (0) secs
delete this clonewhen gf clickedI got ninja'd oof. Yeah if you're ok with an uglier simpler solution use Za-Chary's solution. Most people are fine with a variable readout, even with that ugly orange backround.
forevah{
render text (join [some variable is ] (some variable))::custom
}@loopArrow::control cap
Thank you supernavo for the quick and very detailed answer, let me see if I can improve that later but quick question: Is good practice to define block names with spaces? Forgive me, I'm just a software developer trying to understand this new language.
Thank you.
- PlNG_
-
Scratcher
500+ posts
"Scratch way" to show text on the screen
you could use the Scratch Labs text blocks.
- TheGlassPenguin
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
you could use the Scratch Labs text blocks.Then you can't import your project into normal Scratch and share it on the normal Scratch community.
Is good practice to define block names with spaces?Scratch doesn't really care if there are spaces in block names, but you can name the blocks whatever, and include spaces. However, creating word sandwiches like “renderText” and “removeRenderedText” can cause a lot of confusion (well, for me in my experience with JavaScript). Basically, it's really up to you if it's “good practice” or not.
- Za-Chary
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
Of course it helps and thanks for the quick reply. A couple of observations if I may:True, but there is a similar block which can fix this:
The first solution will not allow a text to say on the screen since it is using the for amount of time block, right?
say [Hello!]
With this block, the sprite will keep saying “Hello!” without stopping. But if you want to, you can have it stop speaking by running this script:
say []
(Here, nothing is in the “say” block, not even a space.)
The second one is good but you have to create a variable, correct? It looks like a waste to me, also I think there is no way to get rid of the surrounding box, right?Yes, you do have to create a variable in order to do this method. You can actually hide and show the surrounding box using the following blocks:
show variable [my variable v]
hide variable [my variable v]
So, it's possible to get rid of the box. (Unless I'm misunderstanding your question? Maybe you meant if it's possible to show just the text and not the orange part of the box — in that case, you are correct, it's not possible to get rid of that box.)
- josh3450
-
Scratcher
5 posts
"Scratch way" to show text on the screen
you could use the Scratch Labs text blocks.Then you can't import your project into normal Scratch and share it on the normal Scratch community.Is good practice to define block names with spaces?Scratch doesn't really care if there are spaces in block names, but you can name the blocks whatever, and include spaces. However, creating word sandwiches like “renderText” and “removeRenderedText” can cause a lot of confusion (well, for me in my experience with JavaScript). Basically, it's really up to you if it's “good practice” or not.
But when you write code you don't only write it for the compiler/interpreter/etc, right? You mostly write it for you and others that later will have to read/maintain the code you wrote, right? I mean we are having here a tool that is mainly intended to introduce coding to kids, correct?
I don't want to comment on your “however” part but it seems to me that is way clearer “render_text text” than “render text text” or even renderText text using camel case, but again, what I take from your answer is that there are no good practices here?
Thank you!
- josh3450
-
Scratcher
5 posts
"Scratch way" to show text on the screen
Of course it helps and thanks for the quick reply. A couple of observations if I may:True, but there is a similar block which can fix this:
The first solution will not allow a text to say on the screen since it is using the for amount of time block, right?say [Hello!]
With this block, the sprite will keep saying “Hello!” without stopping. But if you want to, you can have it stop speaking by running this script:say []
(Here, nothing is in the “say” block, not even a space.)The second one is good but you have to create a variable, correct? It looks like a waste to me, also I think there is no way to get rid of the surrounding box, right?Yes, you do have to create a variable in order to do this method. You can actually hide and show the surrounding box using the following blocks:show variable [my variable v]
hide variable [my variable v]
So, it's possible to get rid of the box. (Unless I'm misunderstanding your question? Maybe you meant if it's possible to show just the text and not the orange part of the box — in that case, you are correct, it's not possible to get rid of that box.)
Sorry, yes, I was talking about the surrounding orange box.
Thanks.
- TheGlassPenguin
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
(#9)You have to determine what “good practices” means for yourself.
But when you write code you don't only write it for the compiler/interpreter/etc, right? You mostly write it for you and others that later will have to read/maintain the code you wrote, right? I mean we are having here a tool that is mainly intended to introduce coding to kids, correct?
I don't want to comment on your “however” part but it seems to me that is way clearer “render_text text” than “render text text” or even renderText text using camel case, but again, what I take from your answer is that there are no good practices here?
It's really up to you if you want to aim for performance or readability, neatness or one massive script for no reason at all.
Either way, basic things such as making your block and broadcast names as clear as you can, and adding code comments/stickies by right-clicking on a script and hitting “Add Comment” and using that to explain what code does, and other stuff that might be important when modifying your code could make it easier for people inspecting the source to figure out how your project works.
- PPPDUD
-
Scratcher
1000+ posts
"Scratch way" to show text on the screen
It is generally considered a good practice for simplicity, however not using spaces is found just fine among the Scratch community.There isn't really an alternative. Well, unless you're OK with it being UGLY… In Scratch, you can basically create a “Text Engine,” or use some other people made. Basically, make a costume for every character you want. Also, preferably also make an “error” character. Then, do something like this.
Here's how I like to do it:when flag clickedThen I put render text in a forever loop.
hide
define render text (text) at x: (x) y: (y)
go to x: (x) y: (y)
set [digit v] to [1]
repeat (length of (text))
switch costume to [Error v]
switch costume to (letter (digit) of (text))
create clone of [myself v]
change [digit v] by [1]
end
when I start as a clone
show
wait (0) secs
delete this clonewhen gf clickedI got ninja'd oof. Yeah if you're ok with an uglier simpler solution use Za-Chary's solution. Most people are fine with a variable readout, even with that ugly orange backround.
forevah{
render text (join [some variable is ] (some variable))::custom
}@loopArrow::control cap
Thank you supernavo for the quick and very detailed answer, let me see if I can improve that later but quick question: Is good practice to define block names with spaces? Forgive me, I'm just a software developer trying to understand this new language.
Thank you.
Last edited by PPPDUD (Dec. 16, 2022 16:13:37)
- hamsterlover2763
-
New Scratcher
1 post
"Scratch way" to show text on the screen
There isn't really an alternative. Well, unless you're OK with it being UGLY… In Scratch, you can basically create a “Text Engine,” or use some other people made. Basically, make a costume for every character you want. Also, preferably also make an “error” character. Then, do something like this.how do you make the pink block thingies?
Here's how I like to do it:when flag clickedThen I put render text in a forever loop.
hide
define render text (text) at x: (x) y: (y)
go to x: (x) y: (y)
set [digit v] to [1]
repeat (length of (text))
switch costume to [Error v]
switch costume to (letter (digit) of (text))
create clone of [myself v]
change [digit v] by [1]
end
when I start as a clone
show
wait (0) secs
delete this clonewhen gf clickedI got ninja'd oof. Yeah if you're ok with an uglier simpler solution use Za-Chary's solution. Most people are fine with a variable readout, even with that ugly orange backround.
forevah{
render text (join [some variable is ] (some variable))::custom
}@loopArrow::control cap
- Discussion Forums
- » Questions about Scratch
-
» "Scratch way" to show text on the screen






