Accessing Elements without Get Element [Guide]

sprinkler

Member
Joined
May 19, 2023
Messages
44
There is an easier method for accessing the elements from an array:-

When we use "View variables from /world, arrays elements are displayed in the output in a [ (ArrayName)ඞ(Index) ] format.

1692369017835.png

Here, my array name is %default% text_split which when viewed through view variable shows as %default% text_splitඞ1. The text on the left side of ඞ character is the array name and the number on right side is the index value.

Do note that while using array blocks, the array index starts at 1, and when using this method the index starts at 0. So while using this method don't forget to decrement 1 from the original index.

So The Method of getting the element is by using a variable which has the name, in the manner specified above. So the variable name would be of the format ArrayNameඞIndex.

Thus the variable name for the above image would be %default% text_splitඞ1 , which will give the SECOND(n-1) index from the array name: %default% text_split.
This can be directly used in actions without having to use an array block to get element.


More Examples:
If array name is PlayerList and you want to get the 10th player in the array, the variable name would be PlayerListඞ9

If array name is BanList and you want to get the first player in it, the variable is BanListඞ0

If array name is Leaderboard and you want to get the third place, the variable is Leaderboardඞ2

Hope this is clear enough
 

deefer

Active member
Joined
May 22, 2023
Messages
358
There is an easier method for accessing the elements from an array:-

When we use "View variables from /world, arrays elements are displayed in the output in a [ (ArrayName)ඞ(Index) ] format.

View attachment 255

Here, my array name is %default% text_split which when viewed through view variable shows as %default% text_splitඞ1. The text on the left side of ඞ character is the array name and the number on right side is the index value.

Do note that while using array blocks, the array index starts at 1, and when using this method the index starts at 0. So while using this method don't forget to decrement 1 from the original index.

So The Method of getting the element is by using a variable which has the name, in the manner specified above. So the variable name would be of the format ArrayNameඞIndex.

Thus the variable name for the above image would be %default% text_splitඞ1 , which will give the SECOND(n-1) index from the array name: %default% text_split.
This can be directly used in actions without having to use an array block to get element.


More Examples:
If array name is PlayerList and you want to get the 10th player in the array, the variable name would be PlayerListඞ9

If array name is BanList and you want to get the first player in it, the variable is BanListඞ0

If array name is Leaderboard and you want to get the third place, the variable is Leaderboardඞ2

Hope this is clear enough
wowowwijeecwvjrut5u5tu5be
 

ItchyDitchy

Member
Joined
Jun 30, 2023
Messages
62
There is an easier method for accessing the elements from an array:-

When we use "View variables from /world, arrays elements are displayed in the output in a [ (ArrayName)ඞ(Index) ] format.

View attachment 255

Here, my array name is %default% text_split which when viewed through view variable shows as %default% text_splitඞ1. The text on the left side of ඞ character is the array name and the number on right side is the index value.

Do note that while using array blocks, the array index starts at 1, and when using this method the index starts at 0. So while using this method don't forget to decrement 1 from the original index.

So The Method of getting the element is by using a variable which has the name, in the manner specified above. So the variable name would be of the format ArrayNameඞIndex.

Thus the variable name for the above image would be %default% text_splitඞ1 , which will give the SECOND(n-1) index from the array name: %default% text_split.
This can be directly used in actions without having to use an array block to get element.


More Examples:
If array name is PlayerList and you want to get the 10th player in the array, the variable name would be PlayerListඞ9

If array name is BanList and you want to get the first player in it, the variable is BanListඞ0

If array name is Leaderboard and you want to get the third place, the variable is Leaderboardඞ2

Hope this is clear enough
Visual representation and example.

1692423554152.png
 
Top