Add item: put one item into a list, a struct staying whole #250

Closed
opened 2026-09-27 21:05:56 +02:00 by meleki · 1 comment
Owner

Adding to a list in a graph only works with Join lists today, and that takes its b apart: a struct becomes one item per field, a list is joined. A list of structs (loot, inventory) cannot grow that way.

Wanted

A data node Add item next to Set item:

  • Inputs list, value, index (default -1).
  • Output result, a new list. The list that came in is left alone, like Set item.
  • value always goes in as exactly one item, a struct or a list included.
  • index -1 or unset appends. Otherwise the item goes in before that index. An index outside the list appends, so the value is not lost.
  • The item takes the kind the list's items share (a texture id in a list of pictures becomes a picture), the same rule as Set item.

Writing back is a Variables node set to Set in the exec flow, as with Set item.

Adding to a list in a graph only works with `Join lists` today, and that takes its `b` apart: a struct becomes one item per field, a list is joined. A list of structs (loot, inventory) cannot grow that way. ## Wanted A data node **`Add item`** next to `Set item`: - Inputs `list`, `value`, `index` (default -1). - Output `result`, a **new** list. The list that came in is left alone, like `Set item`. - `value` always goes in as exactly one item, a struct or a list included. - `index` -1 or unset appends. Otherwise the item goes in before that index. An index outside the list appends, so the value is not lost. - The item takes the kind the list's items share (a texture id in a list of pictures becomes a picture), the same rule as `Set item`. Writing back is a `Variables` node set to *Set* in the exec flow, as with `Set item`.
Author
Owner

Done in b90b628.

  • Add item (data): inputs list, value, index (default -1); output result, a new list. The list that came in is left alone.
  • value goes in as exactly one item, a struct or a list included (unlike Join lists).
  • index -1 or unset appends, otherwise the item goes in before that index; an index outside the list appends.
  • The item takes the kind the list's items share. The rule moved out of Set item into fitToSlot, which both nodes use.

Tests: gate 2634 tests green; 7 catalog cases, 4 in list-of-structs.test.ts, index among the whole-number inputs. Counter-check: taking the value apart like Join lists fails 3 tests. No e2e check for this node.

Wiki: Behaviors (node list).

Done in b90b628. - **Add item** (data): inputs `list`, `value`, `index` (default -1); output `result`, a new list. The list that came in is left alone. - `value` goes in as exactly one item, a struct or a list included (unlike `Join lists`). - `index` -1 or unset appends, otherwise the item goes in before that index; an index outside the list appends. - The item takes the kind the list's items share. The rule moved out of `Set item` into `fitToSlot`, which both nodes use. Tests: gate 2634 tests green; 7 catalog cases, 4 in `list-of-structs.test.ts`, `index` among the whole-number inputs. Counter-check: taking the value apart like `Join lists` fails 3 tests. No e2e check for this node. Wiki: [Behaviors](https://git.nockal.com/meleki/game-maker/wiki/Behaviors) (node list).
admin added this to the Development project 2026-09-27 22:17:06 +02:00
admin moved this to Done in Development on 2026-09-27 22:17:42 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#250