Create a basket
const items = ["Sword", "Potion"]
debug.log(items[0])
Indices start at 0. This prints Sword.
Shared contents
Assigning a basket does not copy it. Both variables refer to the same contents.
const a = [1, 2]
const b = a
b[0] = 99
debug.log(a[0])
This prints 99. Use basket.clone(a) for a separate outer copy. Nested baskets are still shared.
Change or search a basket
basket.insert(items, "Map")
const index = basket.find(items, "Potion")
if index != nil {
debug.log(items[index])
}
Basket search finds a value inside a basket. It does not search World objects.
Reference
See the Basket API for insertion, removal, sorting, copying, and freezing. Mutation of a frozen basket reports an error.