Typed lists: a list whose items are one struct type #254

Closed
opened 2026-09-27 22:16:10 +02:00 by meleki · 2 comments
Owner

Follows the struct asset. Today a list declares nothing about its items: every struct item carries its own fields, so + Item ▸ Struct starts an empty struct, and a list like Loots needs Name, Pool and the rest typed in again for every item.

Idea

  • A list (variable, struct field) gets the setting Items with "Mixed" (today) or a struct asset.
  • With a type, + Item creates one item of that struct with the asset's defaults, and every item is brought into that shape on load and whenever the asset changes (field added, removed, renamed, like typed struct variables).
  • "Make struct type" on a list of structs creates the asset from the shape of its items and types the list.
  • For each → Expand and Add item → Pack can then pick the type once and follow it.

Open

  • What happens to items that do not fit when a mixed list gets a type (dropped, or brought into shape)?
  • Does Add item check the kind on a typed list, or does it stay a plain list at runtime as the struct asset does?

Lists stay dynamic until this is done.

Follows the struct asset. Today a list declares nothing about its items: every struct item carries its own fields, so `+ Item ▸ Struct` starts an empty struct, and a list like `Loots` needs `Name`, `Pool` and the rest typed in again for every item. ## Idea - A list (variable, struct field) gets the setting *Items* with "Mixed" (today) or a struct asset. - With a type, `+ Item` creates one item of that struct with the asset's defaults, and every item is brought into that shape on load and whenever the asset changes (field added, removed, renamed, like typed struct variables). - "Make struct type" on a list of structs creates the asset from the shape of its items and types the list. - `For each` → `Expand` and `Add item` → `Pack` can then pick the type once and follow it. ## Open - What happens to items that do not fit when a mixed list gets a type (dropped, or brought into shape)? - Does `Add item` check the kind on a typed list, or does it stay a plain list at runtime as the struct asset does? Lists stay dynamic until this is done.
admin added this to the Development project 2026-09-27 22:17:14 +02:00
admin moved this to Next in Development on 2026-09-27 22:17:55 +02:00
  1. eine liste mit gemischte werten soll nicht in umwandelbar sein (meldung in der console)
  2. add item, ebenfalls eine meldung in der console, typed lists dürfen nur den passenden typed structs erhalten

zusatz: in einer (heutigen) mixed liste, soll man bei einem einzelnen struct item trotzdem auch den type auswählen können (sowie bei structs die nicht in einer liste sind)

1. eine liste mit gemischte werten soll nicht in umwandelbar sein (meldung in der console) 2. add item, ebenfalls eine meldung in der console, typed lists dürfen nur den passenden typed structs erhalten zusatz: in einer (heutigen) mixed liste, soll man bei einem einzelnen struct item trotzdem auch den type auswählen können (sowie bei structs die nicht in einer liste sind)
Author
Owner

Done in b0d0868.

What it does

  • A list variable and a list field have the row Items: Mixed, any struct asset, or Make struct type (collects every field any item has).
  • A typed item carries its type as $struct. The key is stripped before the game sees the value, so at runtime a struct stays a plain object.
  • A list holding anything but structs refuses a type (also via overrides); the console names the list and the count.
  • In a typed list + Item adds an item with the defaults, field names are locked, values stay editable. Field rows take their kind from the struct asset, so an Asset field shows the asset picker (was a text field).
  • A struct item in a mixed list has its own Type row. Back to Mixed keeps the type on each item.
  • Renames/adds/removes on the struct asset reach typed items everywhere, including overrides and nested lists, in one undo step. The delete dialog counts typed lists.
  • Add item and Set item have the setting Type: with a type they only accept a struct with exactly its field names, anything else is left out and logged.
  • The item indent from #252 is back to its old width.

Not done: writing a variable does not check the type, the List node offers no type.

Tests

  • ./check.sh: 183 files, 2679 tests, CHECK EXIT 0
  • e2e GM_STEPS=1,21,22,32,54,55: ALL PASSED, 150 checks (1-6 included before the follow-up: 404)
  • New tests/core/typed-lists.test.ts, e2e module 55 (13 checks). Counter-checks bite in unit and browser.

Wiki: Structs, Behaviors, Development (d4f6ca3).

Done in b0d0868. **What it does** - A list variable and a list field have the row **Items**: Mixed, any struct asset, or *Make struct type* (collects every field any item has). - A typed item carries its type as `$struct`. The key is stripped before the game sees the value, so at runtime a struct stays a plain object. - A list holding anything but structs refuses a type (also via overrides); the console names the list and the count. - In a typed list `+ Item` adds an item with the defaults, field names are locked, values stay editable. Field rows take their kind from the struct asset, so an Asset field shows the asset picker (was a text field). - A struct item in a mixed list has its own Type row. Back to Mixed keeps the type on each item. - Renames/adds/removes on the struct asset reach typed items everywhere, including overrides and nested lists, in one undo step. The delete dialog counts typed lists. - **Add item** and **Set item** have the setting *Type*: with a type they only accept a struct with exactly its field names, anything else is left out and logged. - The item indent from #252 is back to its old width. **Not done:** writing a variable does not check the type, the List node offers no type. **Tests** - `./check.sh`: 183 files, 2679 tests, CHECK EXIT 0 - e2e `GM_STEPS=1,21,22,32,54,55`: ALL PASSED, 150 checks (1-6 included before the follow-up: 404) - New `tests/core/typed-lists.test.ts`, e2e module 55 (13 checks). Counter-checks bite in unit and browser. Wiki: [Structs](https://git.nockal.com/meleki/game-maker/wiki/Structs), Behaviors, Development (d4f6ca3).
admin moved this to Done in Development on 2026-09-28 19:27:51 +02:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#254