Skip to content

Commit 773aa52

Browse files
authored
Link "structure" and "for each" pages to one another (#799)
1 parent 0672bb1 commit 773aa52

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

  • docs/gdevelop5
    • all-features/variables/structures-and-arrays
    • events/foreach-child-variable

docs/gdevelop5/all-features/variables/structures-and-arrays/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Arrays can be created in the Variables Editor, using events or by using an exten
4141

4242
Array variables should only contain children of the same type, here numbers. When you need a mix of numbers and strings (or even only several numbers), you can make each child a structure as explained in the [Array of structures](#array-of-structures) section.
4343

44-
## Accessing child variables in structures or arrays
44+
## Access child variables in structures or arrays
4545

4646
Variables that exist within a collection variable (i.e: an array or a structure) are known as _child variables_.
4747
To access the value of a child variable, use the following syntax in an [expressions](/gdevelop5/all-features/expressions), replacing the values in angled brackets with variable names:
@@ -77,7 +77,7 @@ Parent variables need to be declared, but it's not the case for children variabl
7777

7878
Just be careful the data doesn't become too difficult to manage if you create structures with a lot of variables.
7979

80-
### Accessing child variables dynamically
80+
### Access child variables dynamically
8181

8282
You can use expressions to dynamically access child variables.
8383

@@ -87,6 +87,10 @@ For example, imagine storing the player's score for each level. If you want to s
8787
Scores.Alice.Levels[CurrentLevel]
8888
```
8989

90+
### Access every child variable
91+
92+
["For each child variable" events](/gdevelop5/events/foreach-child-variable) give the child variables from structure variables (or arrays) one at a time to their sub-events.
93+
9094
### Array of structures
9195

9296
Array variables can contain structure variables. It allows to have several values for one index.

docs/gdevelop5/events/foreach-child-variable/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ title: For each child variable event
33
---
44
## For each child variable (of a structure or array)
55

6-
**For each child variable** events give the [child variables](/gdevelop5/all-features/variables/) from structure variables (or arrays) one at a time to their sub-events.
6+
**For each child variable** events give the child variables from [structure variables (or arrays)](/gdevelop5/all-features/variables/structures-and-arrays) one at a time to their sub-events.
77

88
This event stores the value of each child variable (as a string or number) and the name of the child variable (as a string) into variables you specify in the parameters of the event. You can use either scene variables or [local variables](/gdevelop5/all-features/variables/local-variables) for the variable to iterate on, for the variable storing the child value, and for the optional variable storing the child name.
99

10+
!!! tip
11+
12+
The ["Array tool" extension](/gdevelop5/extensions/array-tools) allows to search, sort, shuffle... without having to make your own loop.
13+
1014
## Local variables
1115

1216
For Each Child Variable events support [local variables](/gdevelop5/all-features/variables/local-variables). Local variables declared in this event are scoped to the loop: they are initialized before the loop starts and are only accessible within the loop and its sub-events.

0 commit comments

Comments
 (0)