How do I use the green Variables?
Can someone show me how to use text variables? Please I need help.
I can explain every block except for the âJoinâ block, Iâve never tried that one out yet.
Characters Between
The âCharacters Betweenâ block is useful for typewriter effects, if you want to make a project, and you want that the text will be âwrittenâ by the game. Example:
W (Waits 100 milliseconds)
WE (Waits 100 milliseconds)
WEL (Waits 100 milliseconds)
WELC (Waits 100 milliseconds)
WELCO (Waits 100 milliseconds)
WELCOM (Waits 100 milliseconds)
WELCOME (Waits 100 milliseconds)
How to use:
Length
This is the length of the text, letâs say that your variable value is Hopscotch8831, when you use âSet Text toâ, and then âLengthâ: âYour Variableâ, it will say â13â because the number of characters of your variable is 13!
Characters At Index
This is pretty much the same as âLengthâ, letâs say your variable value is Hello864, and you use âSet Text toâ, and then âCharacters At Index:4â, then it will say âoâ because the 5th character of your variable is âoâ! The reason why you think you should enter 5 when you want the 5th character to show up is because the 1st character of your variable is the 0th character length-wise.
How to use:
If you still donât understand, I can make a project to make it easier for you!
And donât feel bad if you donât understand : )
take the world hello
. character at 1 is e
because itâs the 1st letter. character between 0 and 2 is he
, because itâs between the 0th and 2th character, 2th being excluded. length returns 5, because hello
has 5 letters. and finally, join abc
with def
returns abcdef
because you have put abc
together with def
.
let us know if you have any other questions!
Thank you for info. I will use
âGreen variables,â otherwise known as Text Operator Blocks, are operators used to manipulate text. There are 4 blocks: Character at Index, Characters in Range, Length, and Join.
- Character at Index takes a single letter at a set index in the specified text.
- The first parameter is where you put in your text.
- The second parameter is the index of the letter you want to return. Index starts at 0, which returns the first letter in the string
- example: Character in (hello) at (1) returns e
- Characters in Range takes letters between a set range in the specified text.
- The first parameter is the same as the parameter in Character at Index.
- The second parameter is for the lower index range
- The third parameter is for the upper index range
- example: Characters in (hello world) between (0) and (5) returns hello
- tip: think of the two indexes as vertical lines placed to the LEFT of the letter at the specified index. The letters within the two lines are the ones it returns. i.e., Characters in (hello world) between (0) and (5) â |hello| world
- Length does exactly what it says. It returns the length of the specified text
- example: length (hello world) returns 11
- tips: emojis are sometimes worth 2 characters instead of one. For every new line, there is an extra invisible character known as the line break (\n), which is worth 1 character.
- Join is a block that was introduced in version 3.63.0; The join block joins two words together (a process also known as âconcatenationâ)
- example: join (hello ) with (world) returns hello world
For more information, refer to the help docs by long pressing a block in the block drawer.
You can also watch the Mad Libs video under âLearnâ to get an idea of how to use the first two text operator blocks.
Dang. Itâs cool how you took your time to type that all out so I could know. Itâs a small world because Iâve been getting around pretty well for being new to the forum.
One thing I forgot to mention, the Addition Math Operator can also be used to join two strings together. However, if only numbers are used, the addition operator will sum the two numbers together whereas join will concatenate them regardless.
5 + 4 = 9
join 5 with 4 = 54
The addition operator used to be the only possible way to join text together, youâll find a lot of project uses this method, and it has pretty much stuck because we are more used to the old method.
sry i donât know.
Is there anything else we can do to help you?
not yet. i have to download hopscotch again