User:Strife Onizuka

From Second Life Wiki
Jump to navigation Jump to search

About Me

I'm an immigrant from URU. Was in all 3 of it's beta's.

Wiki Gnome (causing drama isn't why I'm here).

I have a webpage but haven't updated it in a few months...

Wiki's are the way of the future when it comes to making documentation Ad-hoc but eventually become static as graffiti grows with popularity as a way of controlling it.

also contribute to some other wiki's History Wiki AviSynth:BlindWanderer

When it comes to writing I tend to go towards concise. A short accurate description is better then a long equally accurate description; less to get confused with, easier to find the important information (because it is all important).

Downloads

Updates: Preview Download
[DMZ] [Preview]
[Agni] [Preview]
[Colo] [Preview]
[Siva] [Preview]
[Durga] [Preview]
[Aditi] [Preview]
[Soma] [Preview]
[Ganga] [Preview]
[Uma] [Preview]

TightList

//Tightlist family of functions Version 1.0
//Copyright Strife Onizuka 2004-2006
//Free to use and distribute as long as this message is not removed.

list TightListParse(string input)
{
    string seperator = llGetSubString(input,(0),(0));//save memory
    return llParseStringKeepNulls(llDeleteSubString(input,(0),(0)), [input=seperator],[]);
}

string TightListDump(list input, string possibles)
{//TLD( complex) makes a string from a list using a seperator that is supposed to be unique to the string
    string buffer = (string)(input);//dump the list without a seperator
    integer counter = -39 - llStringLength(possibles);
    if(counter == -40)
        if(!~llSubStringIndex(buffer,possibles))
            jump end;//woot, we were given a unique seperator
    possibles += "|/?!@#$%^&*()_=:;~`'<>{}[],.\n\" qQxXzZ\\";//Good character set of rarely used letters.
    do; while(~llSubStringIndex(buffer,llGetSubString(possibles,counter,counter)) && (counter=-~counter));//search for unique seperator

    possibles = llGetSubString(possibles,counter,counter);

    @end;
    buffer = "";//save memory
    return possibles + llDumpList2String((input = []) + input, possibles);
}

integer TightListTypeLength(string input)
{
    string seperators = llGetSubString(input,(0),6);
    return ((llParseStringKeepNulls(llDeleteSubString(input,(0),5), [],[input=llGetSubString(seperators,(0),(0)),
           llGetSubString(seperators,1,1),llGetSubString(seperators,2,2),llGetSubString(c,3,3),
           llGetSubString(seperators,4,4),llGetSubString(seperators,5,5)]) != []) + (llSubStringIndex(seperators,llGetSubString(seperators,6,6)) < 6)) >> 1;
}

integer TightListTypeEntryType(string input, integer index)
{
    string seperators = llGetSubString(input,(0),6);
    return llSubStringIndex(seperators, input) + ((input = llList2String(llList2List(input + llParseStringKeepNulls(llDeleteSubString(input,(0),5), [],[input=llGetSubString(seperators,(0),(0)), llGetSubString(seperators,1,1),llGetSubString(seperators,2,2),llGetSubString(seperators,3,3), llGetSubString(seperators,4,4),llGetSubString(seperators,5,5)]), (llSubStringIndex(seperators,llGetSubString(seperators,6,6)) < 6) << 1, -1),  index << 1)) != "");
}

list TightListTypeParse(string input) {
    list partial;
    if(llStringLength(input) > 6)
    {
        string seperators = llGetSubString(input,(0),6);
        integer pos = ([] != (partial = llList2List(input + llParseStringKeepNulls(llDeleteSubString(input,(0),5), [],[input=llGetSubString(seperators,(0),(0)), llGetSubString(seperators,1,1),llGetSubString(seperators,2,2),llGetSubString(seperators,3,3), llGetSubString(seperators,4,4),llGetSubString(seperators,5,5)]), (llSubStringIndex(seperators,llGetSubString(seperators,6,6)) < 6) << 1, -1)));
        integer type = (0);
        integer sub_pos = (0);
        do
        {
            list current = (list)(input = llList2String(partial, sub_pos= -~pos));//TYPE_STRING || TYPE_INVALID (though we don't care about invalid)
            if(!(type = llSubStringIndex(seperators, llList2String(partial,pos))))//TYPE_INTEGER
                current = (list)((integer)input);
            else if(type == 1)//TYPE_FLOAT
                current = (list)((float)input);
            else if(type == 3)//TYPE_KEY
                current = (list)((key)input);
            else if(type == 4)//TYPE_VECTOR
                current = (list)((vector)input);
            else if(type == 5)//TYPE_ROTATION
                current = (list)((rotation)input);
            partial = llListReplaceList(partial, current, pos, sub_pos);
        }while((pos= -~sub_pos) & 0x80000000);
    }
    return partial;
}

string TightListTypeDump(list input, string seperators) {//This function is dangerous
    seperators += "|/?!@#$%^&*()_=:;~`'<>{}[],.\n\" qQxXzZ\\";
    string cumulator = (string)(input);
    integer counter = (0);
    do
        if(~llSubStringIndex(cumulator,llGetSubString(seperators,counter,counter)))
            seperators = llDeleteSubString(seperators,counter,counter);
        else
            counter = -~counter;
    while(counter<6);
    seperators = llGetSubString(seperators,(0),5);

        cumulator =  "";

    if((counter = (input != [])))
    {
        do
        {
            integer type = ~-llGetListEntryType(input, counter = ~-counter);

            cumulator = (cumulator = llGetSubString(seperators,type,type)) + llList2String(input,counter) + cumulator;
        }while(counter);
    }
    return seperators + cumulator;
}

Float <-Union-> Integer

integer fui(float a)
{//union float to integer
    integer b = (a<0) << 31;
    if(a)
    {
        if((a = llFabs(a)) < 1.1754943508222875079687365372222e-38)
            return b | (integer)(a / 1.4012984643248170709237295832896e-45);
        integer c = llFloor(llLog(a) / 0.69314718055994530941723212145818);
        if(c > 127){c = 127;}
        if((a /= (float)("0x1p"+(string)c)) < 1){a*=2; --c;}
        return ((c + 127) << 23 ) | (integer)((a - 1) * 8388608.0) | b;
    }
    return ((string)a == (string)(-0.0)) << 31;
}

float iuf(integer a)
{//union integer to float
    integer c= (a >> 23) & 0xff;
    float b = (a & 0x7fffff) * 1.1920928955078125e-7;
    if(c == 0xff)
        b = 1 / 0; //NaN or Infinity (since getting them crashes the script, thats we do).
    else if(c)
        b = (b + 1) * (float)("0x1p"+(string)(c - 127));
    else
        b = b * 1.1754943508222875079687365372222e-38;
    return b * ((a >> 31) | 1);
}

string hexc="0123456789ABCDEF";

string int6hex(integer x) 
{
    integer x0 = 0;
    string res = "";
    integer c = 26;
    do res += llGetSubString(hexc,x0 = (x >> c-=4) & 0xf , x0); while(c > 0); 
    return res;
}

float iuf_alt(integer a)
{//union integer to float
    integer c = (a >> 23) & 0xff;
    float b;
    if(c == 0xff)
        b = 1 / 0; //NaN or Infinity (since getting them crashes the script, thats we do).
    else if(c)
        b = (float)("0x1."+int6hex(a << 1)+"p"+(string)(c - 127));
    else
        b = (a & 0x7fffff) * 1.4012984643248170709237295832896e-45;
    return b * ((a >> 31) | 1);
}

Float Compare

integer FloatCompare(float a, float b, integer c)
{//compare floats and allow for a margin of error, requires fui().
    if(a - b)//(c) Strife Onizuka 2006 
    {//they are not equal
        //First we convert the floats to integer form, as they would be in memory;
        integer a_i = fui(a);
        integer b_i = fui(b);
        integer a_e = (a_i >> 23) & 0xff;
        integer b_e = (b_i >> 23) & 0xff;
        if(!(a_e || b_e) || //to disable the +/- roll under support put a // just before the !
            ((a_i & 0x80000000) == (b_i & 0x80000000)))//sign match check
        {//start by getting and testing the difference, this is what limits c
            integer diff = a_e - b_e;//ugly is fast, basicly, it gets the mantissa, sets the sign on the mantisa,
            if(diff >= -1 || diff <= 1)//shifts it depending on exponent, finaly executes the test.
                if(llAbs(((((a_i & 0x7FFFFF) | (!!a_e << 23)) * ((a_i >> 31) | 1)) >> !~-diff) - 
                         ((((b_i & 0x7FFFFF) | (!!b_e << 23)) * ((b_i >> 31) | 1)) >> !~diff)) <= c)
                    jump out;
        }
        return (a > b) - (a < b);
    }
    @out;
    return 0;
}

BitCount

integer bitcount(integer n)
{//MIT Hackmem 169, modified to work in LSL
    integer tmp = n - ((n >> 1) & 0x5B6DB6DB)//modified mask
                    - ((n >> 2) & 0x49249249);
    return (((tmp + (tmp >> 3)) & 0xC71C71C7) % 63) + (n < 0);
}