Collection
A list, like a shopping list.
sword, shield, potionObject
A card with labelled boxes, like settings.
prefix: !, color: #F5C842New to all this? You can build almost everything with Number, Text and User variables. Come back to Collections and Objects when you feel ready.
Collections (lists)
A Collection is a list, like a shopping list:Change a list with Save a value
Pick a Collection variable in the Save a value block and you get a Collection Operation menu:Add things
Add things
Change things
Change things
Take things out
Take things out
Read a list
In
.each[...], $value is the thing, $number counts 1, 2, 3, and $name, $price (any key) read that key of the item. \n means a new line.
Objects (named keys)
An Object is like a card with labelled boxes on it. Each box has a name (a key) and holds something:Change an object with Save a value
In Save a value, pick an Object variable and choose an Object Operation:
The block on the canvas then says what it does, for example Remove shop.coins, so you can read your canvas at a glance.
Read a key
Put a dot and the key name after the variable:Starting properties
When you make an Object variable (or a User variable that stores an Object), you can add Starting properties: the named values every new entry begins with. Press Add property to add one. For example, addcoins = 0, gems = 0 and title = Newbie. Now every new member starts with exactly those boxes filled in.
You can set Starting properties in the builder’s Create New Variable window and on the Database page.
Objects for every member
A User variable can also store an object, so each member has their own card, like{DBVAR_pet.name} and {DBVAR_pet.happiness}. In Save a value or Do the maths, fill in the Key box to change just one part.
Example: a tiny shop
1
Make the variable
Make a Collection variable called
shop.2
Fill it
In a Save a value block, pick
shop, choose Add item and write name=Potion, price=50.3
Show it
In
/shop, add a Reply with: