Difference between revisions of "List"
(substituied list of functions by List category) |
(reverted to some of the info in the old wiki entry) |
||
Line 2: | Line 2: | ||
[[Category: LSL Types]] | [[Category: LSL Types]] | ||
[[Category: LSL List]] | [[Category: LSL List]] | ||
Instead of arrays, LSL uses lists. The list {{LSLG|type}} is exactly what it sounds like: a heterogeneous list of the other data types. Lists are created via {{LSLG|csv|comma-separated values (CSV)}} of the other data types. enclosed by square brackets: "[" and "]". See below for examples of the {{LSLG|syntax}}. | |||
Lists not only store the {{LSLG|value}} of the list item, but also its type (see {{LSLG|llGetListEntryType}} and {{LSLG|llCSV2List}}). To directly enter a {{LSLG|float}} {{LSLG|value}} into a list, a decimal point (.) must be used. | |||
<pre> | |||
Because they store multiple value types, lists are not accessed with square brackets like arrays are. They are read by accessor {{LSLG|functions}} that specify the type of value attempting to be retrieved (e.g. {{LSLG|llList2Integer}}) and written with accessor functions that insert or replace values (or ranges of values) based on new list {{LSLG|variables}} (e.g. {{LSLG|llListReplaceList}}). | |||
Note: while the {{LSLG|LSL}} {{LSLG|compiler}} will only accept {{LSLG|code}} with a maximum of 72 items in a list, lists can actually support as many items as a {{LSLG|script}}'s {{LSLG|memory}} will allow. If a list of more than 72 predefined items is needed, just {{LSLG|concatenate}} (combine) two predefined lists into a new one: longlist = firstpart + secondpart; | |||
Lists cannot contain other lists, so using them like a multidimensional array is not possible natively (although several ways around this are available). Also, {{LSLG|stride|strided}} lists can be used. | |||
Examples: | |||
<pre>//a list with a string, integer, float, vector and rotation | |||
list l = ["somestring",12,3.0,<3.3,4,0>,<0,0,0,1>];</pre> |
Revision as of 10:46, 18 February 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Instead of arrays, LSL uses lists. The list type is exactly what it sounds like: a heterogeneous list of the other data types. Lists are created via comma-separated values (CSV) of the other data types. enclosed by square brackets: "[" and "]". See below for examples of the syntax.
Lists not only store the value of the list item, but also its type (see llGetListEntryType and llCSV2List). To directly enter a float value into a list, a decimal point (.) must be used.
Because they store multiple value types, lists are not accessed with square brackets like arrays are. They are read by accessor functions that specify the type of value attempting to be retrieved (e.g. llList2Integer) and written with accessor functions that insert or replace values (or ranges of values) based on new list variables (e.g. llListReplaceList).
Note: while the LSL compiler will only accept code with a maximum of 72 items in a list, lists can actually support as many items as a script's memory will allow. If a list of more than 72 predefined items is needed, just concatenate (combine) two predefined lists into a new one: longlist = firstpart + secondpart;
Lists cannot contain other lists, so using them like a multidimensional array is not possible natively (although several ways around this are available). Also, strided lists can be used.
Examples:
//a list with a string, integer, float, vector and rotation list l = ["somestring",12,3.0,<3.3,4,0>,<0,0,0,1>];