| 1 | = Repeat = |
| 2 | The repeat object is designed to simplify cases where you have a large number of very similar objects nearby each other. |
| 3 | == Explanation == |
| 4 | The repeat object generates "count" copies of any objects nested within it. Since you can not have multiple copies of the same named object you insert "[n]" somewhere in the name. After parsing, the "n" is replaced with the index of the generated object in the repeat. |
| 5 | |
| 6 | '''Important:''' The repeat element does not automatically adjust child element sizing. |
| 7 | == Example == |
| 8 | For example, the following XML could be simplified by using a repeat element. |
| 9 | {{{ |
| 10 | #!xml |
| 11 | <object name="myObj[0]" type="sprite" sprite="mySprite"/> |
| 12 | <object name="myObj[1]" type="sprite" sprite="mySprite"/> |
| 13 | <object name="myObj[2]" type="sprite" sprite="mySprite"/> |
| 14 | }}} |
| 15 | The next snippet uses the repeat element to create the same result. |
| 16 | {{{ |
| 17 | #!xml |
| 18 | <repeat count="3"> |
| 19 | <object name="myObj[n]" type="sprite" sprite="mySprite"/> |
| 20 | </repeat> |
| 21 | }}} |