Welcome to The Guide!
Today, we’ll be focusing on the block saving powers of text strings!
Text strings are extremely underrated and not very well known. They are technical, but once you begin to understand them, I’m sure you can think of all sorts of things they can be useful for!
In this guide, I will give all of my knowledge of what text strings are, how they work, and how you can use them in your games! Strap yourselves in, and let’s dive into the technical side of text strings!
What are text strings?
Text strings are great ways to store lots of information into a single text block! This can be useful for storing strings of text (obviously), but are also surprisingly efficient at storing numbers! Here are some examples of systems that utilize text strings:
How to Track Every Player and Find Their Distance [ 🟥 8/10]
Memory Efficient Trigger Keyboard 🤯 (Only takes 1% memory)
How do text strings work?
Text strings can be tricky at times, and aren’t always the solution. Although they can be used to hold information that’s always changing, they’re best used with storing constant information that never changes.
Here’s the equation that finds the first letter of the substring we’re trying to get:
B = (S * L) - (L - 1)
Confusing? Let me break it down for you. B is the beginning, or the starting letter, of the substring we’re trying to get. S is the actual substring we’re trying to get. L is the length [1] of each substring. Still don’t quite make sense? Let’s use an example from Fleet’s guide from above. His string was:
abcdefghijklmnopqrstuvwxyz
If we use the equation from above, we can pick out a few different things.
B = y
S = x
L = 1
y = (x * 1) - (1 - 1)
Is it starting to make sense? I hope so! Let’s plug in a number for x and see what happens!
x = 7
(7 * 1) - (1 - 1) = 7
But, we can obviously simplify! We can remove all of that complicated math, because our answer will just end up being 7 anyways!
Now what do we do with this? We can now easily get the number from the text string using another simple equation.
A = in text "insert text string here" get substring from (letter number v) (B) to (letter number v) (B + (L - 1))
We use our B and our L - 1 from earlier to find our A (answer) and finally get the desired text string. Let’s plug in our 7 from earlier and see what we get.
B = 7
L = 1
in text "abcdefghijklmnopqrstuvwxyz" get substring from (letter number v) (7) to (letter number v) (7 + (1 - 1)) = g
However, we can simplify! Since we know we’re only trying to get substrings that are only 1 character long, we can just get the letter number!
in text "abcdefghijklmnopqrstuvwxyz" get (letter number v) (7) = g
And there you have it! We can now find any data we want from a text string! As long as you follow these equations, you should have a pretty good idea on how you can use text strings to save block code!
A more complex example
I’ve recently found that you can also use text strings for… numbers? How does that work?
A while ago, the user TorontoBulls1 showed me a great way to convert text into numbers!
I wanted to make a system for my game that would purchase an item, but it wouldn’t grant an actual item. Instead, it would increase a counter that sets a property. I came up with a few systems that I could use to tackle this issue.
-
Use trigger block code to broadcast messages to vending machines. +2165 memory.
-
Use a large line of checkers to check a property to see how much cash I owed and how much cash I had. +2080 memory.
-
Use a text string with block code in a trigger to find out how much cash I owed and use a system I already built into my game that takes away a players cash. +540 memory.
I decided that I would try to test out #3. I wasn’t sure if it would work, since there were numbers that were 1 character long, and others that were 2 characters long. To test this out, I went into another map, trying to convert a text string of 001 to see if it was equal to 1. The test was successful, and I went to implement it into my map! Here is the block code I used:
You can see all of the equations from earlier. Let’s use our equations to figure out how this works. We’ll use the number 11 for our S.
B = y
S = 11
L = 2
y = (11 * 2) - (2 - 1) = 21
A = y
B = 21
L = 2
y = in text "02050710151822283042552036" get substring from (letter number v) (21) to (letter number v) (21 + (2 - 1)) = "55"
Now, we can simplify our equations.
y = (11 * 2) - 1 = 21
A = in text "02050710151822283042552036" get substring from (letter number v) (21) to (letter number v) (21 + 1) = "55"
They’re simple changes, but every block counts in Gimkit’s block code!
We got the string 55! Now we can convert it into a number, and take away that amount of cash!
I hope you learned some things about text strings today, and go on to use them in some interesting ways! I’m sure theres some great memory and / or block saving ideas in your head already! Happy building Gimkitters!
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- Amazing!
- Good!
- Okay.
- Needs improvement.
- Bad.
- Terrible.
- Worst. Guide. Ever.
You found the easter egg! What should you do? Reply telling me how much you love (or hate) this guide, provide some helpful feedback, and put an egg emoji at the end of your reply! ↩︎