Overview
A short guide on how to use Collections in your game.
What are Collections?
Collections hold data in a list format that can be searched, edited, added to or removed from at runtime. You can for example use them to store things the player has done, enemies destroyed, items unlocked and much much more. This guide assumes some experience with Use Values in 001 Game Creator.
Events related to Collections
Collection Events
Adds a new element to the collection.
Removes everything inside a Collection.
Takes the left path if the chosen Collection contains the parameter. If not if takes the right path.
Checks if the Collection has the specified amount of items in it. This will take the left path ONLY if the Collection contains exactly that amount of items. In some cases it can therefore be better to use a Comparison Branch to count the Collection, as this lets you use Greater Than, Less Than and so on.
Goes through every element inside the collection and can do scripts based on the current item. Requires a variable to hold the current loop information.
Copies data from one Collection into the Destination collection.
Changes an item on a specified Index inside a collection to a new value. This can be tricky to use, since you need to know the exact Index of the item you want to edit. Since this isn’t always the case, we can instead search through the Collection to find the correct Index using the Find in Collection use value.
This will return the index number of the value searched for. If we don’t find anything, it returns 0.
Inserts a new value at a specified Index.
Removes the value from a Collection if it’s found.
Similar to Edit Element in Collection, except that this event removes the entry from the Collection.
Sort a a collection either by alphabetical or numerical, ascending or descending. This can come in handy if you need to sort items in the players inventory for example.
Collection Use Values
Like all global variables, Collections has their own set of Use Values that you can make use of in your game. The use value code is written inside [ ].
Returns how many entries are inside a collection.
Searches the Collection for the parameter and returns the index the parameter was found at.
Makes a new Collection from a set of values. Use it with Variable Operations like the example below to make that variable into a collection you can use in your scripts.
Merges two collections together and returns them as a string. Use this with variable operations like in the example.
Returns each element inside a collection into a string with an optional delimiter. For example if you have a collection that contains “Item 1” “Item 2” “The Third Item” it would return as “item 1, item 2, the third item” with , being the delimiter. You can use whatever character you want as the delimiter, but I recommend using comma.
Returns x entries inside a collection starting from the TOP of the list.
Returns the x entries inside a collection starting from the BOTTOM of the list.
Returns the x entries inside a collection starting from a custom Index in the list then continuing down.
Returns a Collection with x entries on the TOP removed.
Returns a Collection with x entries on the BOTTOM removed.
Returns a Collection with a set amount of entries cut from the Top and Bottom.