How Lists work
By CodeAlpaca
One of Flowlabs most complex behaviors is the List. Users often find this behavior daunting to learn and ignore one of the most useful behaviors available. As one of the foremost experts in how the List behavior works, here is a detailed document with example images to help.
Before we begin, you must know how Lists work. A List is used to contain a set of values in a specific order, to help aid here is a visual example.
[CODE ALPACA,
DRAMA LLAMA,
HELLO,
WORLD]
Those are the items contained in the List, the words “CODE ALPACA” and “DRAMA LLAMA” are a single item even though it is separated by a space. In case you are confused this may help you understand it more.
Let’s only have 1 item to start. I will place a number before the word to indicate the Index (index is just the placement of an item within the list)
[(1) CODE ALPACA] This is a list containing a single item, if I was to add a value with the “Push” input (more on that later on) the list would now look like this
[(1) CODE ALPACA, (2) DRAMA LLAMA] another item has now been added to the List. This is the basic concept of how the list works, so now we will go more in-depth into how it works.
—-
Number List.
(The order in which I list the inputs are not the same as on the behavior, this is done to place similar features near each other to help make it easier to understand. I also refer to the Numbers inside of the List as “items”, that is because Number Lists and Text Lists are very similar and I wanted to reinforce the similarities between them)
- The Number List has several inputs attached to it, the first is the “Set” input. This input allows the user to Set a new List. (Note: You can only use the “Set” input with a List of the same type, ex. Number List → Number List or Text List → Text List) Setting a List works the same as if you were going to set a Number or Global.
(ex. If you had the List [1, 5, 10] you could use the “Set” input to make another List also contain the values [1, 5, 10])
- The “All” input will output the List, similar to the “Get” input on a Number.
- The “Push” input adds an item to the end of the List, this item is dependent on what the input was. If you had a list of [1, 2, 3, 4, 5] and inputted 4 into the “Push” input the List would now be [1, 2, 3, 4, 5, 4] *(This is similar to using the “+” input on the Text behavior)
(Note: This is what I was showing above with the example “[(1) CODE ALPACA, (2) DRAMA LLAMA]”)
- The “Pop” input works in a similar manner to the “Push” input, but instead of adding an item to the end of the List, it removes one instead. If you had a list containing the number [1, 2, 3, 4, 5], inputting ANY number into it would remove the last item in the list, making it [1, 2, 3, 4].
(Note: The “Pop” output will output the item that is removed from the list, so in the example shown above the outputted value would be 5)
- The “Join” input connects all the items in the list together with what ever the inputted value was. If you had a list containing the values [1, 3, 2, 4, 3] and inputted the value ”PIE” into the “Join” input, you would get an output of “1PIE3PIE2PIE4PIE3”. That may look a little confusing, but if I had used another value as the input it would look cleaner, like this “1,3,2,4,3”.
(Note: This should be pretty clear, but the outputted value is a Text value, meaning it will be purple)
-
The “One” input outputs the value at the selected index. What this means is if you input 3 to a list of [100, 150, 200, 300, 350] the output you would receive is 200. That is because it is the 3rd item in the list. If you input a value greater than the total number of items inside the list you would get the last item on the list as an output. (If you input a number less than 1 you would receive the first item in the list)
-
The “Find” input searches the list for the value that is inputted, if the item is not found you will receive an output of 0. So if you input 4 into the “Find” input of this list [100, 150, 200, 300, 350], you would receive an output of 0. If you instead inputted 150, you would get an output of 2 (This is the items place in the list)
Those are all of the features of a Number List. A Number List is no different than a Text List except for the fact that it can only accept Numbers, while a Text List can have both Numbers AND Text as input.
So now that you know how to use the #1 most useful behavior (excluding basic things like Number) you can finally give up the excuse of not using it! When I say this I’m not joking. Lists are soo powerful. And please share this with anyone who doesn’t know how to use lists, I don’t like looking at people use a ton of Routers, Filters, and Switches to solve a problem a single List could >:(
Example of how powerful Lists are
- When I eventually remake Alpaca Raceway using a single List I will be able to let the player create however many levels they want.
- With a single List, I could have several WRs for every map.
- I don’t want to spoil my current project, but with Lists I’m making probably the most advanced thing on Flowlab (personal opinion). I did start this project in august and forgot about it for a while because of the cotton jam, but now I’m back at it again!
If you have any other questions feel free to ask. (I do plan on making these for all of the other List behaviors)