Skip to reading
Panels, Tabs & List Boxes

19. Fill a list from an Array

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

Use an Array source when game data should decide which rows exist. For example, a clue list can grow as the player learns things, while the GUI keeps the same layout.

1. Create an Array variable named clue_rows. Give it the object records below as its initial value.

2. Select the List Box. Set Item Source to array and Array Variable ID to clue_rows.

3. Use a different variable, selected_array, for Selected Item Variable. Make that a String for a single-select list.

4. Start a game preview and check that the rows appear.

Code example
[
  {"id": "bell", "text": "The bell rang at midnight"},
  {"id": "window", "text": "The upper window was open"},
  {"id": "oil", "text": "Oil on the workshop floor"}
]

Figure 28. Array Variable ID points to the source Array. Selected Item Variable is still a separate output.

Use a real Array value. A String containing quoted JSON is still a String; it is not the same data type.

Page 32 of 50Permalink
Go to page