A B C D E F G I J K L M N O R S T U V W

Variables, function parameters, and return values have types. This means that a value stored in a variable, bound to a function parameter, or returned by a function must be of the same type, or it must be converted to the same type.

LSL provides a set of seven basic types that are used throughout the language:

Type Brief Description
integer A whole number ranging from -2,147,483,648 to 2,147,483,647
float A decimal number ranging from 1.175494351E-38 to 3.402823466E+38
vector Three floats in the form < x , y , z >. Usually a position, color, or Euler rotation
rotation A quaternion rotation, made up of 4 floats, < x , y , z , s >
key A UUID (specialized string) used to identify something in SL, notably an agent, object, sound, texture, other inventory item, or dataserver request
string A sequence of characters, limited only by the amount of free memory available to the script.
list A heterogeneous list of the other data types.

To convert between different types of values, use typecasting. An explicit typecast looks like this: ((newType)expression). Implicit typecasting will convert integers to floats or strings to keys.

For example, to say an integer, it must be converted to a string:

integer x = 5;
llSay(0, (string)x);

 

Constant Value Function
TYPE_INTEGER 1 Indicates that the list entry is holding an integer.
TYPE_FLOAT 2 Indicates that the list entry is holding a float.
TYPE_STRING 3 Indicates that the list entry is holding a string.
TYPE_KEY 4 Indicates that the list entry is holding a key.
TYPE_VECTOR 5 Indicates that the list entry is holding a vector.
TYPE_ROTATION 6 Indicates that the list entry is holding a rotation.
TYPE_INVALID 0 Indicates that this wasn’t a valid list entry.
Occurs when passing an index greater than the length of the list or less than the negative length of the list.

This function can be used to loosely determine the type of a variable. Make sure to improve it if you plan to use it for userdata.

// Writen by Chad Statosky
integer GetType(string var)
{
    integer n =     llGetListLength(llParseStringKeepNulls(var, ["1", "2", "3", "4"], [])) - 1;
            n +=    llGetListLength(llParseStringKeepNulls(var, ["5", "6", "7", "8"], [])) - 1;
            n +=    llGetListLength(llParseStringKeepNulls(var, ["9", "0", ".", "<"], [])) - 1;
            n +=    llGetListLength(llParseStringKeepNulls(var, [">", " ", ",", "-"], [])) - 1;
    if(n == llStringLength(var))
    {
        if(llSubStringIndex(var, "<")  != -1 || llSubStringIndex(var, ">") != -1)
        {
            if(llGetListLength(llParseStringKeepNulls(var, [","], [])) == 3)    return TYPE_VECTOR;
            else                                                                return TYPE_ROTATION;
        }
        else
        {
            if(llSubStringIndex(var, ".") != -1)                                return TYPE_FLOAT;
            else                                                                return TYPE_INTEGER;
        }
    }
    else
    {
        if(llStringLength(var) == 36 && 
                llGetListLength(llParseStringKeepNulls(var, ["-"], [])) == 5)   return TYPE_KEY;
        else                                                                    return TYPE_STRING;
    }
}

 Credit to: Lslwiki.net (not working) with changes made for brevity and clarity.