What are arrays or rays?

I see this so often and have absolutely 0 idea what they mean.

An array is like a table:


index | 0 | 1 | 2 | 3


value | A | x | % | 9


You have the values stored in an array (in this case characters) and a corresponding index wich starts with 0 (because 0 is the first binary number). You can directly access the values using their index. Arrays are used to store multiple data values of the same type.

2 Likes

Thanks for the reply. But I’m a little confused, isn’t that what player/global variables are?

A variable can store exactly one data value. But this “data value” can be an array, used to extend the storing space.

1 Like

Arrays are, in programming terms, a data structure, a collection of items.

Basically, variables can hold (be assigned) strings such as “Hello”, numbers like 123 or 3.14 or objects like Players or Heroes, and they can also hold “arrays”.

In an array you can have everything a variable can hold, indexed by numbered,

A := [ 3.14, “Hello”, Player0 ]

here we have the variable A holding an array of size 3.

Each position in the array (from 0 to size-1, 0 to 2 in this case), can be retrieved or changed.

A[0] holds the number 3.14
A[1] holds the string “Hello”
A[2] holds the Player object Player0

In the workshop you can modify arrays by using

Set player variable at index
Set global variable at index

you can also use

Set player variable
Set global variable

to set a variable to an empty array, there is also many other commands to tamper with arrays.

2 Likes

This may work for Python and yes, indeed it works for workshop, but you cant store multiple data types in one array in the most programming languages. Just as a sidenote :slight_smile:

2 Likes

OHHH that makes so much sense!
Thank you so much!!! this will help sooooo much!!!
Thank you Shanalotte and Kurinoku for the help! I’ll get coding and hopefully be able to share my workshop modes for the community to enjoy :smiley:

2 Likes

Oh yeah, indeed it only works for dynamically typed languages, I just didn’t want to get too technical since I was already bringing some
technicalities… Also, just as a sidenote, the workshop’s array forbid adding an array to another array, I believe when trying to do that It’ll fuse the contents of both arrays.

1 Like