Don't click here unless you want to be banned.

LSL Wiki : ExampleListConversion

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org

Example List Conversion


Here's a snippet that converts lists to strings and back while preserving the actual element type. This is useful for passing lists via chat or link messages, etc. Drop it into your code and away you go.

This version uses the newer dump/parse functions. Props to the author of the original which can be found here.

Feel free to use and modify this in your own code for any purpose.

WARNING: Be careful passing floats by themselves or as part of a vector. The way LSL does string conversion on floats can result in inaccuracies at the 6th significant digit. For more info see float.

////////////////////////////////////////////////////////
// snip list convert // ready jack // 11 Nov 2005 // 1.0
string slc_sep = "#!$"; // funky name for clean namespaces

string list_2_string(list l) {     
    list result = [];
    integer len = llGetListLength(l); // optimization
    integer i; 
    for (i = 0; i < len; ++i) {
        result += [llGetListEntryType(l, i)] + llList2List(l, i, i);
    }
    return llDumpList2String(result, slc_sep);
}

list string_2_list(string s) {
    list l = [];
    list result = [];
    l = llParseStringKeepNulls(s, [slc_sep], []);
    integer len = llGetListLength(l);
    integer i;
    for (i = 0; i < len; ++i) {
        integer type = (integer) llList2String(l, i);
        ++i; // CLEVERNESS WARNING...BE VERY AFRAID
        if (type == TYPE_INTEGER) result += (integer)llList2String(l, i);
        else if (type == TYPE_FLOAT) result += (float)llList2String(l, i);
        else if (type == TYPE_KEY) result += (key)llList2String(l, i);
        else if (type == TYPE_VECTOR) result += (vector)llList2String(l, i);
        else if (type == TYPE_ROTATION) result += (rotation)llList2String(l, i);
        else result += llList2String(l, i);
    }
    return result;
}
//////////////////// snip list convert /////////////////


Examples Jasa SEO Jasa SEO Murah Sepatu Online Toko Sepatu Online Sepatu Sepatu Murah Sepatu Safety Sepatu Futsal Cheapes Hostgator Coupon Link Booking Televisori offerte Notebook Offerte Berita Terkini Internet Marketer Muda Internet Marketer Indonesia Portatile Apple RDAnet Lorks Karikatur Bisnis Modal Kecil Bisnis UKM Berita Terbaru Iklan Baris Jasa SEO Jasa SEO Murah SEO Indonesia Konsultan SEO SEO Belajar SEO Kursus SEO Kursus SEO Murah Jam Tangan Casio Jam Tangan Casio Jam Tangan Murah Jam Tangan Grosir Baju Terbaru Grosir Baju Baju Terbaru Grosir Baju Murah Bisnis Online Belajar SEO Kerupuk Kerupuk kulit Social Bookmark Dofollow Social Bookmark Kumpulan Puisi Kirim Puisi bola hantu Penumbuh Rambut Penumbuh Rambut timbangan WBC Wonogiri Jasa SEO Murah Jasa SEO Jam Tangan Murah
There are 5 comments on this page. [Display comments/form]