All about Text Blocks! Classified Berkian Information!

Welcome to another guide! This one I made because in all the guides about beginner coding, (and advanced), there hasn’t been a lot of talk about text blocks, and I’m not talking length of and the normal set texts, I’m talking about first occurrences and sub-strings. But, for the sake of the guide, I’ll include all the blocks. We can break this down into 2 different sections, the Beginner and Advanced. We’ll start with the beginning first.

Wiki editing rules

Please don’t make any of the edits violate the TOS or FAQ, remember, anyone can see who edits a wiki and what part they edit.
Please be responsible!
Everyone, please don’t edit when it is being edited.
Ask before editing and tell me what you’re going to add.
Add yourself to the credits if you edited it and added something.
Don’t make credits using @ since you can only do that 10 times in a post.


Table of Contents

  • Set Text
  • Create Text
  • Length Of
  • Convert Numbers To Text
  • Get Sub-string letter# to letter#
  • Get letter#
  • Find first occurrence

Set Text
This is the most common block used, obviously, I won’t have to explain much because even beginner coders can catch up pretty quickly on this. Usually, without using the block itself, (i.e. the text that is offered by notifications and pop-ups), text appears a lot, but the times where the block is used, is probably used when you concatenate strings, or in actually form, use Template Literals, which I actually explained before. Text blocks can be a value for properties also! They can also be manipulated, as explained in the other text blocks.


Create Text
A still very common block, create Text can conjoin multiple pieces blocks to make a whole string. An interesting thing about this is numbers, now, if you’ve used blocks before, you know it’s possible to convert numbers to strings (with commas), and text can do that! However, there appears to be certain restrictions. When you try broadcasting using numbers, say, the property of something is set to a number, 1234, and you want to broadcast on a concatenated string 1234h, well, I tried this out and it didn’t work, meaning that when broadcasting, it can’t convert numbers to string automatically, the best way to do this might be using the converted text to numbers (using commas), but if it’s a normal concatenation, like:

set text: item 1: get property propertyName
          item 2: set text: "Whatever you wish!"

It works!


Length Of
Pretty self-explanatory, right? The length of the block basically gives you the length of a string, and I did a test, it’s not 0-based, meaning it starts at index 1, I can’t fully remember which data types start at index 1, pretty sure though arrays and objects are 0-based.


Convert Numbers To Text
Now, this one is pretty simple, but small warning, remember the Create Text section?
Just to be sure, when I mean (using commas) I don’t mean putting a comma after every number, I mean adding the comma at every 3 digits. For example, 1234, use the converter and you get 1,234. So you would also need to be wary to add the commas when needed in your broadcasts.

That pretty much sums it all up.


Now we’re moving on to advanced! These blocks are not as used and have more specific


Get Sub-string letter# to letter#
This part of it cuts out pieces of text from the string. For example.

string: "This is an example";
sub-string: letter6 to letter18

You would get “is an example”. Now, to let you know, the letter6, it includes the letter, and not the next one. To explain, the 6th letter is “I”, so it includes it, not go to the next letter, which is “s”.


Get Letter#
For this, it works virtually the same as the letter# to letter# except for one thing, it instead gets you the letter index. For example, using our example above, lets pick letter2, well, we would get “h” if we wired this to a notification or pop-up. I’m not entirely sure why it wasn’t made to go all the way to the end of the string, but maybe it was so that you could get more specific letters to build together with. (reminds me of when your typing on your phone and some words appears that match what you’ve began typing for some reason).


Find First Occurrence
And, now, the most important for last, and the reason I made this Guide, the occurrence block. Now, what this does is that it finds the occurrence, like the find button shortcut. Now, this isn’t all it does, and there’s a secret thing that people might not know about if you don’t experiment, it also tracks the number of occurrences, even before the thing is triggered. Now, I discovered this during my Battleship game, the goal for the occurrence was to identify if an updated property had the word “Enemy”. I triggered 3 “Enemy” buttons that updated the property, and then ran the trigger, getting a notification of ‘3’, the same amount of triggers I triggered with “Enemy” in it. What I assume is that the updated properties are stored somewhere and that the occurrence block goes through those updates, and while it does activate since the property already has “Enemy” in it, it also stores the total amount of times “Enemy” was stored. Just saying, I would suggest asking Blockhole to explain more about this part, since they literally are [1] the best coders in the forums, (that might be Clic-Clac though), they could help clear this part out.


And that’s it! While the most important part was the occurrence part of it, I did want to explain all the text blocks, so that I could explain it to them. Hope this helps, signing off, Friends of Berk!

Lemme know if I missed anything, or have a suggestion on what to add!

Credits

Toothless
(Hopefully others soon!)

8 Likes

great Guide @Toothless !

1 Like

Thanks!

1 Like

You should add about the subtypes of letter# blocks like last letter, first letter, etc.
You should also talk about some concatenation and how you can connect the find first occurrence of text block into the get letter# blocks. Great guide though! This’ll be very useful to new block coders!!!

2 Likes

This is a good guide! It should be a wiki!

2 Likes

Didn’t I explain that?

1 Like

If you want, I can make this a wiki and you add that!

Make means asking a regular. :sweat_smile:

3 Likes

Not from what I read…

3 Likes

Anytime but a wiki is a good idea and me love blocks.

Ok! :+1:

2 Likes

…mini guide?
what?

this is a great guide, but a long guide, 'cause how does someone explain all this info so fast? maybe remove the mini guide part?

anyway, nice guide.

3 Likes

Awesome explanation and great overall structure, you’ve made complex concepts so accessible!
I will suggest to insert some pictures as well.
yoyleberries

4 Likes

ya it’s long not mini

Oh, if that’s the case, you can add that! :smile:

1 Like

Removed the mini guide part of it!

1 Like

@Blackhole927 could you make this a wiki for toothless?

2 Likes

Hopefully, @Blackhole927 will reply soon, because I already added the wiki stuff.

1 Like

Should we add about limits of some of the blocks and getting past them? Although the getting past the limits is not utilizing more than text blocks.

Well, I wanted this guide to explain what the text blocks do, but I guess it seems okay if people mention about how to get pass them, it could become a “Everything you need to know about text blocks” kind of guide instead, which it already is sorta! If you add what you suggested, it’ll work I think!

2 Likes

I want a wiiki so bad!!! =b

2 Likes