Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.
MJ edited this page Apr 13, 2016 · 1 revision

Arrays

LML supports array types required by some attributes. Currently, only complex multi-argument methods (like ScrollPane#setupOverscroll) and macros actually need array types (more on macros later), but its still good to know how they work.

Array values are separated by ; marker. The simplest LML array would look like this: text0;text1;text2.

Arrays support method elements (proceeded with $). If the method element returns a Java non-primitive array or iterable, its elements will be converted to string and added to the LML array. For example, if the method with "key" ID returns new Object[] { 1, "value" }, this array: "someValue;$key" will be parsed as "someValue;1;value" array.

There are also ranges, which can be a part of the array. Range iterates from start to end, adding each number to the base text. Ranges are very useful for multi-line bundle texts. For example, @menuPrompt[0,2] will match @menuPrompt0;@menuPrompt1;@menuPrompt2 array. An example of more complex array with ranges: [0,2];value;text[-3,-1] matches: 0;1;2;value;text-3;text-2;text-1.

Arrays can be passed in LML arguments (see: Arguments) - if argument object turns out to be any non-primitive Java array or Iterable, it will be converted to a LML array, allowing you to iterate over Java collection directly in your LML templates.