Discuss Scratch

GabElla_I
Scratcher
64 posts

How to make variables into text!

Variable -Text

Sometimes the variable displays look really bad, and maybe you'd want to make it into better text without the weird frame and a better font.

You'll need:
(Word)
(variable for all sprites)
and
(this letter)
(variable for only one sprite)

Set the number variable to whatever number to display.

Make a sprite with different costumes, one costume for each letter.
eg:
costume1 for sprite 1 looks like an A
costume2 for sprite 2 looks like a B
. . . etc . . .

But for now, only make 1 sprite.
when green flag clicked
set [Word v] to [whatever]
set [this letter v] to [1]
go to x: (0) y: (0)
forever
end

make your own block to make life easier
define if this letter of (variable) = (letter)
if <(letter (this letter) of (variable)) = (letter)> then
switch costume to (letter)
end
make sure your costume name matches the letter the costume looks like

now, your script should be:
when green flag clicked
set [Word v] to [whatever]
set [this letter v] to [1]
go to x: (0) y: (0)
forever
if this letter of (number) = (A)
if this letterof (number) = (B)
end

and so on . . .

Duplicate your sprite the number of letters you need.
For each sprite, change:
  • the variable
    (this letter)
  • x and y position of sprite

That's all you need!

(this letter)
should always match the place of the letter
eg:
ABCDEFG
for the C sprite,
<(this letter) = [3]>
--Explosion--
Scratcher
1000+ posts

How to make variables into text!

Hi there! Welcome to the forums! This is a nice guide but this isn't the place for it This forum is for requesting art and code from others and lending your skills to other's requests. This type of this would be better as an article on the Scratch Wiki, if you want to help others with their scripting problems ask go to the Help With Scripts forum. Anyways; scratch on!

–Explosion–
-Master-Mind-
Scratcher
1 post

How to make variables into text!

when green flag clicked
set size to (200) %
go to x: (-120) y: (135)
forever
if <(number) > [10]> then
switch costume to [(((number) mod (10)) + (1)) v]


else
switch costume to [((number) + (1)) v]
end
end

Last edited by -Master-Mind- (July 17, 2021 00:20:42)

DemonMaster777
Scratcher
15 posts

How to make variables into text!

im pretty sure theres a limit because for example if a variable was somehow set to 100000000000000000000000000000000000000 you'd have a hard time doing that
btw the new scratch blocks are supposed to make this much easier
thx for the help though

Powered by DjangoBB