llList2Key
key llList2Key(list ListVariable, integer Index)Copies the key at Index in the list.
Returns the value at Index in the specified list. If Index describes a location not in the list, or the value cannot be type-cast to a key, then null string is returned.
Parameters
-
ListVariable(list) -
Index(integer)
This function extracts a key value from a list at a specified index. If the index is out of bounds or the value cannot be type-cast to a key, a null string is returned.
Examples
Section titled “Examples”default{ state_entry() { list my_list = ["a", 1, 2.0, <1,2,3>, <1,2,3,4>, llGetOwner()]; integer i; for (i=0; i<llGetListLength(my_list); ++i) { llOwnerSay("string=" + llList2String(my_list,i) + "\n integer=" + (string)llList2Integer(my_list,i) + "\n float=" + (string)llList2Float(my_list,i) + "\n vector=" + (string)llList2Vector(my_list,i) + "\n rot=" + (string)llList2Rot(my_list,i) + "\n key=" + (string)llList2Key(my_list,i) ); } }}This example demonstrates iterating through a mixed-type list and extracting each element as different types, including keys. The output appears in Chat History (Ctrl+H).
- Returns null string ("") if the index is out of bounds
- Returns null string ("") if the value cannot be type-cast to a key
- To check what type an element actually is before extracting it, use
llGetListEntryType() - For more information on working with lists in LSL, see the list iteration guide