Use repeaters

From Wiki Let's Role

Repeaters are tools that allow you to dynamically add views. They are very useful for managing inventories, lists of skills, or all of a character’s actions.

Create Repeater

Step 1: Create two subviews

Create two subviews: an edit view and a read view.

  • Edit view: contains the form fields that the user will fill.Add components such as TextInput, Checkbox, List, NumberInput, Textarea, Choice, etc. Assign a clear and unique id to each field.
  • Read view: displays the information entered in the edit view.

Use Label components and reference the edit view fields using #field_id. This will automatically copy and update the data.

Step 2: Insert the Repeater component

Insert a Repeater component in your main view.

Step 3: Link the views to the Repeater

In the Repeater properties, set:

  • the edit view
  • the read view

Step 4: Add views

Add new views by clicking the Add button of the Repeater.

  • The first view displayed is the edit view.
  • Once you press the Done button, the edit view is replaced by the read view.

Communication between edit and read views

The edit view stores the information, and the read view displays it.

Simple example:

  1. In the edit view, add a TextInput component with the id test_input.
  2. In the read view, add a Label component.
  3. In its text field (right panel), enter #test_input and check Computed.
  4. Test the repeater: add a new view, type "hello" in the field, and click Done.

→ The label in the read view will display hello.

To display multiple values in the same Label, concatenate them: "The value is: " + #test_input + " and " + #test_input2

Conditional display

You can show a default value when no field is set, using the conditional function:

"The value is: " + if(#test_input=0, "[No value]", #test_input)

  • If no text is entered → The value is: [No value]
  • If "hello" is entered → The value is: hello

Other Repeater tutorials

  • Setting actions on Repeater buttons
  • Moving a view from one Repeater to another
  • Changing the order of views in a Repeater