• Hey! Register here to create your account, engage with the community, and talk about what is new!

List Basics

RyanLand

Well-known member
Overlord
Joined
Sep 6, 2020
Messages
60
Reaction score
39
Hello! Today I'm going to teach you the basics of lists. This thread has been designed for beginners.

What are lists?

Lists are, well... a list. See it as a grocery list: There's a few things on it (in order), but you can remove and add new things to buy at any time, anywhere in the list. For coders: they are identical to arrays.

You will see the word "index" pop up a lot too. An index is basically the number of the value. For example, if Apple would be third on my grocery list, it's index would be 3.

Actions

We are going to be going over a few important list actions today. Major list manipulation actions can be found in the Set Variable (Iron Block) block, under List Manipulation.

The first action in here is Create List. It takes a variable to set the list to, followed by any values for it to contain. Not putting any values in will generate an empty list. If the list is already set, this action will ignore that and re-define the list.

Next is Append Value. It simply adds one value or multiple to the end of the list.

And last is Append List. It will append all values from list B to the end of list A.

Another useful feature of lists is Repeat: ForEach. It will iterate over each value in the list, "for each" value. The first variable in the chest will be set to the value of the index equal to the current repeating iteration. The second parameter is the actual list itself.

List Usage

Can I use lists outside of list actions? Yes!
Any chest parameter that accepts multiple values for the parameter will work with lists. For example, take a list of items. Give Items allows you to give multiple items at once, so you can simply put the list of items in the chest and it will work!

Final Words

Those are all the actions we are going to talk about today. If you have any questions, I'd love to answer them in the replies!

- RyanLand
 
Last edited:

grobulae

Moderator
Moderator
Joined
Sep 6, 2020
Messages
127
Reaction score
26
Nice tutorial, but I think it could do with a few improvements:
Create List vs. SetVar(=)
Sublists
Useful Examples (Matching Lists?)
 

Wobber

Forum adept
Overlord
Joined
Sep 6, 2020
Messages
1,515
Reaction score
103
so this is the same number as my user. nice
 

HellishBro

Active member
Joined
Nov 11, 2022
Messages
47
Reaction score
3
also, nested lists are lists within lists, to do this, use append list on the target list, and in the parameters use a variable that is the list you want to nest
 
Top Bottom