Add
Appends a value to a list and returns a new list that includes it. Lists in StoryBonsai are immutable, so the result only persists if you assign it back to the list variable through a Set Variable event. Add is idempotent: adding a value that is already a member returns the list unchanged, with no duplicate created.
Category: List
Returns: list
Signature
Add(list, value)
The first argument is a list-typed variable. The second is the value to add.
Examples
These are typed into the Value field of a Set Variable event whose Variable picker targets the same list:
Add(var_inventory, "item_key") // add a key to inventory
Add(var_party, "char_kim") // Kim joins the party
Add(var_flags, "met_merchant") // record that the merchant was met
Add(var_inventory, "item_key") // no-op: the key is already there
Notes
The value must be a quoted string literal, or a variable that holds one. A
bare, unquoted word that is not a declared variable, such as item_key
without quotes, is not valid here and raises an error when the expression
runs.
Membership is case-sensitive, so "item_key" and "Item_Key" count as
different values. That also makes Add’s idempotency check, and
Remove’s matching, case-sensitive.