- 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
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: