| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"/> |
| 5 | <title>Variables & Containers - QtFRED Help</title> |
| 6 | <link rel="stylesheet" type="text/css" href="../css/help.css"/> |
| 7 | </head> |
| 8 | <body> |
| 9 | <nav class="breadcrumb"><a href="../index.html">QtFRED Help</a> › Mission › Variables & Containers</nav> |
| 10 | <h1>Variables & Containers</h1> |
| 11 | <p>Opens via <strong>Editors › Variables</strong>.</p> |
| 12 | <p>Declares named variables and containers that <a href="../concepts/sexps.html">SEXPs</a> |
| 13 | can read and write during the mission. Variables hold a single value; containers hold |
| 14 | collections of values. Both are referenced in SEXPs by name and can be used throughout |
| 15 | the event system to track state, accumulate data, and communicate between events.</p> |
| 16 | |
| 17 | <h2>Variables tab</h2> |
| 18 | <p>The main list shows all variables in the mission with their name and default value. |
| 19 | String type variables are colored blue while numeric type are color orange. |
| 20 | The list is filterable. Use <strong>Add</strong>, <strong>Copy</strong>, and |
| 21 | <strong>Delete</strong> to manage entries. Double-click a variable's name or value to |
| 22 | edit it inline.</p> |
| 23 | |
| 24 | <h3>Variable properties</h3> |
| 25 | <table> |
| 26 | <tr><th>Field</th><th>Description</th></tr> |
| 27 | <tr><td>Name</td><td>The identifier used to reference this variable in |
| 28 | SEXPs.</td></tr> |
| 29 | <tr><td>Default value</td><td>The value the variable starts with at the beginning |
| 30 | of the mission.</td></tr> |
| 31 | <tr><td>Type</td><td><em>Number</em> or <em>String</em>. Variables are explicitly |
| 32 | typed and the type cannot be changed at runtime.</td></tr> |
| 33 | </table> |
| 34 | |
| 35 | <h3>Persistence</h3> |
| 36 | <p>Controls when a variable's value is saved between missions. The |
| 37 | <strong>Eternal</strong> checkbox (only available when a persistence mode is |
| 38 | selected) controls <em>where</em> it is saved: unchecked saves to the campaign file |
| 39 | (value is scoped to the current campaign); checked saves to the player's pilot file |
| 40 | (value persists across all campaigns and is always available).</p> |
| 41 | <table> |
| 42 | <tr><th>Setting</th><th>Description</th></tr> |
| 43 | <tr><td>No persistence</td><td>The variable exists only for the duration of this |
| 44 | mission. Its value is reset each time the mission starts. Eternal is not |
| 45 | available.</td></tr> |
| 46 | <tr><td>Save on Mission Completed</td><td>The variable's value is saved when the |
| 47 | player accepts the mission outcome in the debriefing. If the player quits |
| 48 | without accepting, the value is not saved.</td></tr> |
| 49 | <tr><td>Save on Mission Close</td><td>The variable's value is saved whenever the |
| 50 | mission closes, whether the player accepted, quit, or restarted.</td></tr> |
| 51 | </table> |
| 52 | |
| 53 | <h3>Network variable</h3> |
| 54 | <p>When checked, the variable's value is broadcast to all players whenever it is |
| 55 | modified during a multiplayer mission, keeping it synchronized across the |
| 56 | session.</p> |
| 57 | |
| 58 | <h2>Containers tab</h2> |
| 59 | <p>Containers hold collections of values. The upper list shows all containers in the |
| 60 | mission and is filterable. List containers are colored blue while map containers are |
| 61 | colored orange. Use <strong>Add</strong>, <strong>Copy</strong>, and <strong>Delete</strong> |
| 62 | to manage containers. Double-click a container's name to edit it inline. Containers |
| 63 | have the same persistence and network settings as variables.</p> |
| 64 | |
| 65 | <h3>Container type</h3> |
| 66 | <table> |
| 67 | <tr><th>Type</th><th>Description</th></tr> |
| 68 | <tr><td>List</td><td>An ordered sequence of values, all of the same type (Number |
| 69 | or String). Items can be added, removed, and iterated in SEXPs.</td></tr> |
| 70 | <tr><td>Map</td><td>A collection of key-value pairs where each key maps to a |
| 71 | value. Keys and values each have their own type (Number or String, |
| 72 | independently). For example, a map with string keys and number values can |
| 73 | associate ship names with scores, or a map with string keys and string values |
| 74 | can work like a set of named labels. SEXPs access map entries by key.</td></tr> |
| 75 | </table> |
| 76 | |
| 77 | <h3>Container contents</h3> |
| 78 | <p>The lower box shows the contents of the selected container and is also filterable. |
| 79 | Use <strong>Add</strong>, <strong>Copy</strong>, and <strong>Delete</strong> to |
| 80 | manage entries, and the arrow buttons to reorder them. Double-click a key or value to |
| 81 | edit it inline. For Map containers, the <strong>Swap</strong> button exchanges a key |
| 82 | and its value.</p> |
| 83 | </body> |
| 84 | </html> |