Lists#
The same rules apply for lists as for variables regarding for all sprites and for this sprite only.
Declaration#
list list_name; # initialized to empty list.
With default values#
list list_name = [1, 2, 3]; # initialized with some default values.
struct point {x, y}
list point points; # empty list of points.
list point points = [100, 200, 300, 400]; # points[1] == point {x: 100, y: 200} and so on...
Read contents from a text file#
This allows you to load a text file line-by-line into a list of strings.
list list_name "filepath.txt";
list type_name list_name "filepath.txt";
If type is specified, each list item is made-up by N lines where N is the no. of fields in type.
Operations#
Add item to list#
add value to list_name;
Delete item from list at index#
delete list_name[index];
Delete all items from list#
delete list_name;
Insert item at index in list#
insert value at list_name[index];
Replace item at index in list#
list_name[index] = value;
Get item at index in list#
value = list_name[index];
Get index of item in list#
index = item in list_name;
Get length of list#
len = length list_name;
Check if item is in list#
if value in list_name {
...
}
Show/Hide List Monitor#
show list_name;
hide list_name;
Get random/last item in list#
value = list_name["random"];
value = list_name["last"];
Compound Assignment#
| Operator | Implementation |
|---|---|
list_name[index]++; |
![]() |
list_name[index]--; |
![]() |
list_name[index] += y; |
![]() |
list_name[index] -= y; |
![]() |
list_name[index] *= y; |
![]() |
list_name[index] /= y; |
![]() |
list_name[index] //= y; |
![]() |
list_name[index] %= y; |
![]() |
list_name[index] &= y; |
![]() |








