How to do stuff in variables

How do I use the green Variables?

8 Likes

Can someone show me how to use text variables? Please I need help.

7 Likes

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 : )

7 Likes

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!

6 Likes

Thank you for info. I will use

5 Likes

“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.

6 Likes

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.

5 Likes

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.

3 Likes

sry i don’t know.

1 Like

Is there anything else we can do to help you?

3 Likes

not yet. i have to download hopscotch again