Indexes, Lists and Number to Text Relations in GKC

WARNING: This Guide Goes Very In Depth
Read at your own risk :skull:

Using a property containing data, I can write something along these lines:
1\Content2\Some More Content3\Even More Content4\

The numbers and slashes are called separators. The numbers in the separators are called indexes and I use \ instead of / because they are less common. This can be used as lists, and more importantly, Number to Text Relations.

Number to Text Relations are ways to interpret values using a number. These numbers could be used to simply relate number 1 to mario, 2 to kirby or 3 to bowser, so instead of using blockcode for to make the value of the character I want to select with:

set property Character to Mario

set property Character to Kirby

set property Character to Bowser

I could use:

Block Code

Now, a counter could be used to update the Selection Number and that number could be used to match the relation meaning only using one block I can create a character selection menu that would usually take X blocks to make where X is the amount of characters you want the player to select from plus one. Now, if I wanted to use a limited trigger loop and a counter, I could use a button to trigger the trigger and select the character, and I could store the data in a property.

So, if I have a property with:

1\Mario2\Kirby3\Bowser4\

And then match a number with the character, I would get the character that the number relates to.


Lists

I can also use this method for lists. Let’s say I’m using Pokémon for this example. The list could store a player’s Pokémon like this::

1\Pichu2\Charizard3\Squirtle4\

And by using a popup, I can display a player’s Pokémon.

I can even put lists into lists like this where x\ is the Pokémon separator and y] are the stats of that Pokémon:

1\1]Pichu2]Electric3]Unevolved2\Charizard


That’s it, thanks for reading, and if you enjoyed this guide, be sure to leave a :heart:, :slight_smile:

8 Likes

Holy that’s a lot of block code other than that really good guide!

1 Like

Block limit final boss :broken_heart:

4 Likes

OML THIS IS ACTUALLY SO USEFUL.
I’m making a PC in gkc, and this is gonna help with the file directory and the MBR in sooo many ways.

:+1:
@Coolcaden26

2 Likes

Additionally, if you can get the items in your list to have a fixed length, you don’t even need separators. For instance, a list of the coordinates (30, 9), (2, 3), (11, 42) could be put in a string as “300902031142”. You can then access each of the numbers in the list using the substring block and some simple math.

2 Likes

The string needs some seperators as 3009 could be read as 3,0 and 0,9

You’d set it up so it’s read in chunks of two, so it would be read as (30, 09). For instance the following block will return the nth number in a list (assuming the list has only two or less digit numbers and one digit numbers have a zero in front of them).

image

In @Apollo’s version you have to find the separators, which takes a lot of code. In my version, there’s an implied separator between every two numbers. Does this clarify things?

2 Likes