Skip to Content
Stoatly Docs
Reference

Collection types

A field's collection type decides how many values it holds. You choose it when you create the field. Formula and Visual fields don't have one. Below are the three options, how each is stored in the record file and how each appears in your code.

The field editor under a group, with the type, collection, label and key.

Scalar

A scalar field holds a single value, or nothing if it isn't required. This is the default.

  • In the record file: the value, for example "damage": 12.
  • In code: a nullable property such as float?, string? or DateTime?. A required field is never null, so it's a plain float, string, DateTime or bool.

List

A list field holds any number of values of its type. The values are kept in order, and you can add, remove and reorder them in the record editor. In the table, a list cell shows a count, and choosing it opens the list editor.

  • In the record file: an array, for example "tags": ["fire", "ranged"].
  • In code: a List<T> that starts empty, such as List<string> or List<float>. A list of enum values is List< followed by the enum's name. A list of references is an IEnumerable of the target's class, and entries that no longer resolve are skipped.

Rules such as a minimum or a maximum apply to single values, so they aren't available on lists.

Quantised list

A quantised list is a list of references where each entry has a quantity. Use it for things like a recipe that needs 3 Iron Ore and 1 Leather, or a drop table with a count for each drop.

In the field editor, Quantity is the maximum number of entries the field can hold. Each entry is a record and a number, and the number defaults to 1.

  • In the record file: an array of objects, for example "ingredients": [{ "ref": "iron-ore", "quantity": 3 }]. The ref is the target record's slug.
  • In code: a List<QuantisedEntry<T>>. Each entry has Ref, the slug, Quantity, the number, and Value, the loaded record.

Choosing one

You wantUse
One valueScalar
Several values of the same kind, in orderList
Several records, each with a countQuantised list

See Field types for which types exist, and Generated C# types for the full mapping.

On this page