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`.
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.
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).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Adding to a list in a graph only works with
Join liststoday, and that takes itsbapart: 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 itemnext toSet item:list,value,index(default -1).result, a new list. The list that came in is left alone, likeSet item.valuealways 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.Set item.Writing back is a
Variablesnode set to Set in the exec flow, as withSet item.Done in
b90b628.list,value,index(default -1); outputresult, a new list. The list that came in is left alone.valuegoes in as exactly one item, a struct or a list included (unlikeJoin lists).index-1 or unset appends, otherwise the item goes in before that index; an index outside the list appends.Set itemintofitToSlot, which both nodes use.Tests: gate 2634 tests green; 7 catalog cases, 4 in
list-of-structs.test.ts,indexamong the whole-number inputs. Counter-check: taking the value apart likeJoin listsfails 3 tests. No e2e check for this node.Wiki: Behaviors (node list).