User:Ugleh Ulrik/Vector2List

From Second Life Wiki
Jump to navigation Jump to search

With many requests on how to easily store a vector to a list, mainly for purposes in storing a [b]llGetPos()[/b] only to capture the x and y cords, this is a simple way.

For Example

list thislist = Vector2List(llGetPos());

As a list, would output

list thislist = [x,y,z];

Function

list Vector2List(vector v){ 
    list alist = llParseString2List((string)v,[",", ">", "<"],[]);
return alist;
}

An Example

list Vector2List(vector v){ 
    list alist = llParseString2List((string)v,[",", ">", "<"],[]);
return alist;
}
default
{

    touch_start(integer total_number)
    {
       list thislist =  Vector2List(llGetPos());

    string x = llList2String(thislist,0);
    string y = llList2String(thislist,1);
    string z = llList2String(thislist,2);
llOwnerSay("X Axis: " + x);
llOwnerSay("Y Axis: " + y);
llOwnerSay("Z Axis: " + z);
    }
}