OverviewAs opposed to a SEXP variable, which stores
only one value, a SEXP container stores
a collection of values.
Consequently, containers allow for handling data in much more sophisticated ways than variables.
Get started with containers using FRED's "Add/Modify Container" dialog, which you can reach from the right-click menu:

The new Replace Container Name/Data submenus are explained below.
Containers come in two types:
- List container - an ordered sequence of values, sort of a cross between Python lists and deques
- Map container - pairs of keys associated with data, like Lua tables or Python dictionaries
Just as variables have a type of either string or number, a container's data and a map container's keys have a type of either string or number.
FeaturesFeature 1: Replace Container Data
Similar to how Replace Variable allows you to access data stored in variables, Replace Container Data allows you to access data stored in containers.
Use one of the following list modifiers to access data in list containers:
- Get_First
- Remove_First
- Get_Last
- Remove_Last
- Get_Random
- Remove_Random
- At
The list modifier options appear in the Replace Data submenu in FRED.
The
At list modifier allows you to access data at a specific position in the list. Specify the index using Number under the Add Data submenu. The first item is at index 0.
The
Get_*/
At list modifiers just retrieve the data, but the
Remove_* modifiers both retrieve the data and remove it from the container.
To access map container data, specify the key using Edit Data.
The container modifier can also be the value of a variable (use Replace Variable), the "special argument" if relevant (use Replace Data), or even a nested usage of Replace Container Data.
Feature 2: Text replacement
Similar to text replacement for variables with
$VariableName$, you can access container data in the text used in
- Command briefings
- Briefings
- Debriefings
- Messages
- Scripting
- Subtitles
- Debug SEXP
For list containers, use the format
&ListContainerName&ListModifier&, where
[ListModifier is one of the modifiers listed above. To access the first data item in the list, use the modifier
At0.
For map containers, use the format
&MapContainerName&MapKey&.
Container data and map keys
are case-sensitive, but container names and list modifiers
are not.
Feature 3: SEXPs and Replace Container Name
You can access these SEXPs from the new Containers subcategories in the Status and Change categories for Replace/Insert/Add Operator.
Status SEXPs- is-container-empty
- get-container-size
- list-has-data
- list-data-index
- map-has-key
- map-has-data-item
Change SEXPs- add-to-list
- remove-from-list
- add-to-map
- remove-from-map
- get-map-keys
- clear-container
FRED's built-in SEXP help explains how they work.
I'm open to adding more SEXPs based on community feedback.

To specify the SEXP arguments that are container names, use the Replace Container Name submenu from FRED's right-click menu. You can specify those arguments using Replace Variable or Replace Container Data, too.
Feature 4: Persistence
Containers support the same persistence options that variables do, except for "Network" (
Issue #3708).
Feature 5: Multidimensionality



For both text replacement and Replace Container Data, you can chain accesses to container data. The data stored in the first container should be formatted as
&ContainerName&.
Unlike the other containers features, there is no equivalent for variables.
Multidimensionality example 1In the above screen shots, if the
random-of in the first screen shot happens to select "Taurus" as the special argument, then the ship "Taurus" will send the message "Ah! A plot is revealed!".
Multidimensionality example 2If I have two map containers,
Map1 and
Map2, and I want to display the data associated with the key "Key 1" from one of the two map containers, selected at random, I'd have a list container called
Maps whose entries are
&Map1& and
&Map2&.
The expression to use in text replacement is
&Maps&Get_Random&Key 1&.
To do the same thing in FRED's SEXP tree, I'd first use Replace Container Data with
Maps using the list modifier
Get_Random, and then I'd add "Key 1" using the String option under the Add Data submenu.
Feature statusAs of the
May 12 nightly, all features are fully supported.
qtFRED doesn't yet have the Add/Modify Container dialog (
Issue #3818) but its SEXP tree should fully support containers.
FeedbackPlease post all questions and comments either in this thread or on the #fred HLP Discord channel.
You can report bugs either here or on GitHub.
NotesThis is a
continuation of karajorma's work from 2014 (
original threads).
Special thanks to
karajorma for creating the feature and testing and also to
Goober5000 and
Cyborg17 for reviewing the containers PRs.
