It can be really annoying when you want to perform standard changes to text, like removing characters, splitting strings, and replacing letters. However, gimkit doesn’t offer those capabilities by default, only the ability to get the length of text, combine text, or convert numbers to text. This can be really annoying, and this guide will explain a way to do more with text, using some math.
The Idea
Think about the device you’re using to read this post. How does it store data? How does it know what words to show you? The answer is numbers. Text and images are stored as numbers on computers, and if a computer can do it then so can we. Let’s make a way to store text as a number. Because computers store text as numbers, and computers can do anything with text, if we store text as a number, then WE can do anything with text.
To do: Boil down to base 72. Add functions. Use decimal places. Rule the world. Autocorrect .
The System
We need a protocol for storing the text. First, we can encode the alphabet with the numbers 10 to 36. This is done so that there isn’t ever a situation where a number starts with zero. Here is an example of helloworld in this text system.
18152222253325282214
If we want to store more characters, like capital letters, punctuation, and spaces, the numbers 37-99 can be used.
And that is how we’ll encode the numbers!
Manipulating Data
A number isn’t what we want, text is! Below are some formulas I came up with for reading/changing this text.
Modulo
This won't directly help you with custom text, but it is used in most of the equations here, and while gimkit does not support it by default, it can be recreated like so:Backspace
A is the number you want to modify.
mod(a, 100) will extract the last two digits of the number. They are subtracted from the number, then the remaining number is divided by 100 to remove the two zeros created by the subtraction.
Appending a letter
A is the number you want to modify, L is the letter (in number code) you want to append.
This equation just multiplies the number by 100, then replaces the zeros at the end with whatever number from 1 to 98 you are appending.
Length of string
A is the number you are getting the length of.The ceiling ceiling log base 10 returns the number of digits in the base 10 representation of the number. Since each encoded character is two digits long, we divide by two to get the number of encoded characters.
Nth character of string
Where a is the number you are working with, l1 is the length of the string, and n is the index of the letter you want to get.
This equation basically just clips out the front and end of the number, to leave the original remaining. a divided by 100 to the power of l1 minus n will result in all the digits we don’t want being moved to decimal places in the number. Then, taking the mod of that number and 100 will get the last two numbers in the remaining number, which is the letter code we want.
A slice of a string
Where a is the string you want to slice, s_1 is the index of the letter you want to start the slice at and s_2 is the index of the letter you want to end the slice at.This equation can be broken down into two sections. First, we have a/100^l_1-s_2. This clips off everything after the end of the slice by moving it into the decimal place values and rounding down.
Then, by taking the modulo of that and 100^s2-s1+1, we can clip off the front of the number. Now, we have the slice we want!
Combining strings
Where a and b are both strings, and l_2 is the length of string b.
This equation “pushes” the a string out of the way by multiplying it by the 100^l_2, leaving a bunch of zeros in the lower place values. Then, by adding the b-string, the zeros are filled, and a new string is created.
Implementing This in GKC
So we have a bunch of equations. You know the theory. Now to get these in GKC.
Functions
Use the guide below to make functions. I'll explain the theory once more. You'll want to use functions for some of these since the block code can get a bit chunky (Like the slicing a string). I'll post the block code, and then show how to make it into a function, if the block code is above 50 blocks.Function Guide:
Another Explanation:
There is a property that counts the number of times a function called in the block. Based on that, the block will choose which code to run. Think about it like this: We are using a characteristic of functions in code. After 1 function has run, only the code where only 1 function will run. After this, we either hit the end of the code or a second function called. After the 2nd function, only the code where 2 functions have run will run. Don’t overthink it. If it sounds too simple to be true, then it is simple.
Modulo
Here is the modulo block code:In this case, since we are using 100, every time it says the variable base, put the number 100 instead. Also, the round down block is in the dropdown for the round block.
Conclusion
And that’s that math! It should be noted that due to properties only being able to store numbers up to 99,999,999,999, each property can only store four characters of encoded text. That is the big tradeoff, less text per property for more control over the text. This system would receive a massive buff if the gimkit team set the max for number properties to the 64 bit limit, but for now it’s only four characters per property. If you’re interested in playing around with all the math here, here is a desmos graph.