Difference between revisions of "User:Anylyn Hax"

From Second Life Wiki
Jump to navigation Jump to search
Line 5: Line 5:
|}
|}


=== str_replace() ===
// No need to cry any more here you got it ...
<pre>
string str_replace (string search, string replace, string str)
{
  integer index;
  integer lenght_of_search = llStringLength(search);
  integer lenght_of_replace= llStringLength(replace);
    do {
    index = llSubStringIndex(str, search);
    str = llDeleteSubString(str, index, index + lenght_of_search -1);
    str = llInsertString(str, index, replace);
    }
    while(~llSubStringIndex(str, search));
    return str;
}
default
{
    state_entry()
    {
        string some_long_string = "aaacccaaacccaaagggaaaggg";
        llOwnerSay(str_replace( "aaa", "bbb", some_long_string ));
    }
}
</pre>
Anylyn Hax 04:48, 9 August 2007 (PDT)


=== StartAnimation-Example ===
=== StartAnimation-Example ===

Revision as of 05:31, 9 August 2007

Anylyn Hax, 500 L$ / 30 min _ _


StartAnimation-Example

For those avatars who need to use another walking animation, other then the one supplied by LL here is a small goodie.

// I like to use Antoinette Lioncourt's sexywalk
// UUID:51e4d6c1-0bf0-f7b9-2cc7-8d7b46baf35b
// place this script in one of your shoes together with the sexywalk
default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION );
    }

    run_time_permissions(integer perm)
    {
        if(PERMISSION_TRIGGER_ANIMATION & perm)
        {
            llSetTimerEvent(.1);
        }
    }
    timer()
    {
        vector vel = llGetVel();
            if( llFabs(vel.x) > 0.1)llStartAnimation("sexywalk");
            if( llFabs(vel.x)<= 0.1)llStopAnimation("sexywalk");
    }   
}

Anylyn Hax 21:43, 1 June 2007 (PDT)

SetPrimitiveParams-Example

// This ugly hack gives out a peace of Human Readable Code, as demanded
// by llSetPrimitiveParams. The result of this program comes via llOwnerSay
// on the chat channel. Its a good idea to cut objectname and date out ;)
// created by Anylyn Hax in the hot summer of 2007.
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


default
{
    state_entry()
    {
        integer i = 0;
        integer ce_side = llGetNumberOfSides();

        list booleans = ([
        "FALSE",                    // 0
        "TRUE"                      // 1
        ]);

        list texgens = ([
        "PRIM_TEXGEN_DEFAULT",      // 0
        "PRIM_TEXGEN_PLANAR"        // 1
        ]);
        
        list holeshape = ([
        "PRIM_HOLE_DEFAULT",        //   0  default (matches the prim type: square for box, circle for cylinder, etc.)
        "","","","","","","","","","","","","","","",
        "PRIM_HOLE_CIRCLE",         //   16  circle
        "","","","","","","","","","","","","","","",
        "PRIM_HOLE_SQUARE",         //   32  square
        "","","","","","","","","","","","","","","", 
        "PRIM_HOLE_TRIANGLE"        //   48  triangle
        ]);
        
        list sculpttype = ([
        "PRIM_SCULPT_TYPE_SPHERE",  //   1  sphere (Converge top & bottom, stitch left side to right)  
        "PRIM_SCULPT_TYPE_TORUS",   //   2  torus (Stitch top to bottom, stitch left side to right)  
        "PRIM_SCULPT_TYPE_PLANE",   //   3  plane (No stitching or converging)  
        "PRIM_SCULPT_TYPE_CYLINDER" //   4  cylinder (Stitch left side to right, leave top and bottom open) 
        ]);
        
        list bumpmapping = ([
        "PRIM_BUMP_NONE",           //   0  none: no bump map  
        "PRIM_BUMP_BRIGHT",         //   1  brightness: generate bump map from highlights  
        "PRIM_BUMP_DARK",           //   2  darkness: generate bump map from lowlights  
        "PRIM_BUMP_WOOD",           //   3  woodgrain  
        "PRIM_BUMP_BARK",           //   4  bark  
        "PRIM_BUMP_BRICKS",         //   5  bricks  
        "PRIM_BUMP_CHECKER",        //   6  checker  
        "PRIM_BUMP_CONCRETE",       //   7  concrete  
        "PRIM_BUMP_TILE",           //   8  crustytile  
        "PRIM_BUMP_STONE",          //   9  cutstone: blocks  
        "PRIM_BUMP_DISKS",          //   10  discs: packed circles  
        "PRIM_BUMP_GRAVEL",         //   11  gravel  
        "PRIM_BUMP_SIDING",         //   13  siding  
        "PRIM_BUMP_LARGETILE",      //   14  stonetile  
        "PRIM_BUMP_STUCCO",         //   15  stucco  
        "PRIM_BUMP_SUCTION",        //   16  suction: rings  
        "PRIM_BUMP_WEAVE"           //   17  weave  
        ]);
        
        list shinys = ([
        "PRIM_SHINY_NONE",          //   0  none  
        "PRIM_SHINY_LOW",           //   1  low  
        "PRIM_SHINY_MEDIUM",        //   2  medium 
        "PRIM_SHINY_HIGH"           //   3  high  
        ]);
        
        list materials =([
        "PRIM_MATERIAL_STONE",      //  0  stone  
        "PRIM_MATERIAL_METAL",      //  1  metal  
        "PRIM_MATERIAL_GLASS",      //  2  glass  
        "PRIM_MATERIAL_WOOD",       //  3  wood  
        "PRIM_MATERIAL_FLESH",      //  4  flesh  
        "PRIM_MATERIAL_PLASTIC",    //  5  plastic  
        "PRIM_MATERIAL_RUBBER",     //  6  rubber  
        "PRIM_MATERIAL_LIGHT"       //  7  light 
        ]);

        llOwnerSay("llSetPrimitiveParams([");

        list ce_prim_flexible =     llGetPrimitiveParams([PRIM_FLEXIBLE]);          // 21
        llOwnerSay("PRIM_FLEXIBLE"+
            ", "+(string)llList2String(booleans ,llList2Integer(ce_prim_flexible,0))+                // true / false
            ", "+(string)llList2Float(ce_prim_flexible,1)+                                            // softness
            ", "+(string)llList2Float(ce_prim_flexible,2)+                                            // gravity
            ", "+(string)llList2Float(ce_prim_flexible,3)+                                            // friction
            ", "+(string)llList2Float(ce_prim_flexible,4)+                                            // wind
            ", "+(string)llList2Float(ce_prim_flexible,5)+                                            // tension
            ", "+(string)llList2Vector(ce_prim_flexible,6)+", ");                                    // force
        ce_prim_flexible =[];

        list ce_prim_material =     llGetPrimitiveParams([PRIM_MATERIAL]);          // 2
        llOwnerSay("PRIM_MATERIAL, "+(string)llList2String(materials ,llList2Integer(ce_prim_material,0))+", ");
        ce_prim_material = [];
        
        list ce_prim_phantom =      llGetPrimitiveParams([PRIM_PHANTOM]);           // 5
        llOwnerSay("PRIM_PHANTOM, "+(string)llList2String(booleans ,llList2Integer(ce_prim_phantom ,0))+", ");
        ce_prim_phantom = [];
        
        list ce_prim_physiks =      llGetPrimitiveParams([PRIM_PHYSICS]);           // 3
        llOwnerSay("PRIM_PHYSICS, "+(string)llList2String(booleans ,llList2Integer(ce_prim_physiks ,0))+", ");
        ce_prim_physiks = [];
        
        list ce_prim_point_light =  llGetPrimitiveParams([PRIM_POINT_LIGHT]);       // 23
        llOwnerSay("PRIM_POINT_LIGHT"+
            ", "+(string)llList2String(booleans ,llList2Integer(ce_prim_point_light,0))+    // true / false
            ", "+(string)llList2Vector(ce_prim_point_light,1)+                              // color
            ", "+(string)llList2Float(ce_prim_point_light,2)+                               // intensity
            ", "+(string)llList2Float(ce_prim_point_light,3)+                               // radius
            ", "+(string)llList2Float(ce_prim_point_light,4)+", ");                         // falloff
        ce_prim_point_light = [];
        
        list ce_prim_position =     llGetPrimitiveParams([PRIM_POSITION]);          // 6
        llOwnerSay("PRIM_POSITION, "+(string)llList2Vector(ce_prim_position ,0)+", ");
        ce_prim_position = [];
        
        list ce_prim_rotation =     llGetPrimitiveParams([PRIM_ROTATION]);          // 8
        llOwnerSay("PRIM_ROTATION, "+(string)llList2Rot(ce_prim_rotation ,0)+", ");
        ce_prim_rotation = [];
        
        list ce_prim_size =         llGetPrimitiveParams([PRIM_SIZE]);              // 7
        llOwnerSay("PRIM_SIZE, "+(string)llList2Vector(ce_prim_size ,0)+", ");
        ce_prim_size = [];
        
        list ce_prim_temp_on_rez =  llGetPrimitiveParams([PRIM_TEMP_ON_REZ]);       // 4
        llOwnerSay("PRIM_TEMP_ON_REZ, "+(string)llList2String(booleans ,llList2Integer(ce_prim_temp_on_rez ,0))+", ");
        ce_prim_temp_on_rez = [];
        
        list ce_prim_type =         llGetPrimitiveParams([PRIM_TYPE]);              // 9
        if(llList2Integer(ce_prim_type,0)==0){llOwnerSay("PRIM_TYPE, PRIM_TYPE_BOX"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", ");}
        if(llList2Integer(ce_prim_type,0)==1){llOwnerSay("PRIM_TYPE, PRIM_TYPE_CYLINDER"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", ");}
        if(llList2Integer(ce_prim_type,0)==2){llOwnerSay("PRIM_TYPE, PRIM_TYPE_PRISM"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", ");}
        if(llList2Integer(ce_prim_type,0)==3){llOwnerSay("PRIM_TYPE, PRIM_TYPE_SPHERE"+", "+(string)llList2Integer(ce_prim_type,1)+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", ");}
        if(llList2Integer(ce_prim_type,0)==4){llOwnerSay("PRIM_TYPE, PRIM_TYPE_TORUS"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", "+(string)llList2Vector(ce_prim_type,7)+", "+(string)llList2Vector(ce_prim_type,8)+", "+(string)llList2Float(ce_prim_type,9)+", "+(string)llList2Float(ce_prim_type,10)+", "+(string)llList2Float(ce_prim_type,11)+", ");}
        if(llList2Integer(ce_prim_type,0)==5){llOwnerSay("PRIM_TYPE, PRIM_TYPE_TUBE"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", "+(string)llList2Vector(ce_prim_type,7)+", "+(string)llList2Vector(ce_prim_type,8)+", "+(string)llList2Float(ce_prim_type,9)+", "+(string)llList2Float(ce_prim_type,10)+", "+(string)llList2Float(ce_prim_type,11)+", ");}
        if(llList2Integer(ce_prim_type,0)==6){llOwnerSay("PRIM_TYPE, PRIM_TYPE_RING"+", "+(string)llList2String(holeshape ,llList2Integer(ce_prim_type,1))+", "+(string)llList2Vector(ce_prim_type,2)+", "+(string)llList2Float(ce_prim_type,3)+", "+(string)llList2Vector(ce_prim_type,4)+", "+(string)llList2Vector(ce_prim_type,5)+", "+(string)llList2Vector(ce_prim_type,6)+", "+(string)llList2Vector(ce_prim_type,7)+", "+(string)llList2Vector(ce_prim_type,8)+", "+(string)llList2Float(ce_prim_type,9)+", "+(string)llList2Float(ce_prim_type,10)+", "+(string)llList2Float(ce_prim_type,11)+", ");}
        if(llList2Integer(ce_prim_type,0)==7){llOwnerSay("PRIM_TYPE, PRIM_TYPE_SCULPT"+", "+(string)llList2String(ce_prim_type,1)+", "+(string)llList2Integer(ce_prim_type,2)+", ");}
        ce_prim_type = [];

        i = 0;
        list ce_prim_fullbright;
        while(i <= ce_side) { 
            ce_prim_fullbright =   llGetPrimitiveParams([PRIM_FULLBRIGHT,i]);                  // 20
            if (ce_prim_fullbright != []) {
            llOwnerSay("PRIM_FULLBRIGHT, "+(string)i+", "+(string)llList2String(booleans ,llList2Integer(ce_prim_fullbright,0))+", ");
            ce_prim_fullbright = []; 
            }           
        i++;
        }

        i = 0;
        list ce_prim_bump_shiny;
        while(i <= ce_side) { 
            ce_prim_bump_shiny =   llGetPrimitiveParams([PRIM_BUMP_SHINY,i]);                  // 19
            if (ce_prim_bump_shiny != []) {
            llOwnerSay("PRIM_BUMP_SHINY, "+(string)i+", "+llList2String(shinys,llList2Integer(ce_prim_bump_shiny,0))+            // shiny
                ", "+llList2String(bumpmapping ,llList2Integer(ce_prim_bump_shiny,1))+", ");// bumpmaping
            ce_prim_bump_shiny = [];
            }
        i++;
        }

        i = 0;
        list ce_prim_color;
        while(i <= ce_side) { 
            ce_prim_color =  llGetPrimitiveParams([PRIM_COLOR,i]);             // 18
            if (ce_prim_color != []) {
            llOwnerSay("PRIM_COLOR, "+(string)i+", "+(string)llList2Vector(ce_prim_color,0)+", "+(string)llList2Float(ce_prim_color,1)+", ");
            ce_prim_color = [];
            }
        i++;
        }

        i = 0;
        list ce_prim_texgen;
        while(i <= ce_side) { 
            ce_prim_texgen = llGetPrimitiveParams([PRIM_TEXGEN ,i]);     // 22 
            if (ce_prim_texgen != []) {
            llOwnerSay("PRIM_TEXGEN, "+(string)i+", "+llList2String(texgens,llList2Integer(ce_prim_texgen,0))+", ");  // type
            ce_prim_texgen = [];
            }
        i++;
        }

        i = 0;
        string koma = "";
        list ce_prim_texture;
        while(i <= ce_side) { 
            ce_prim_texture = llGetPrimitiveParams([PRIM_TEXTURE,i]);     // 17
            if(i < ce_side -1) { koma = ", "; }                                          // we dont put everywhere a komata
            if (ce_prim_texture != []) {
            llOwnerSay("PRIM_TEXTURE, "+(string)i+
                ", "+(string)llList2String(ce_prim_texture,0)+                      // name
                ", "+(string)llList2Vector(ce_prim_texture,1)+                      // repeats
                ", "+(string)llList2Vector(ce_prim_texture,2)+                      // offsets
                ", "+(string)llList2Float(ce_prim_texture,3) + koma);                 // rotation
            ce_prim_texture = [];
            koma = "";
            }
        i++;
        }

        llOwnerSay("]);");
        llOwnerSay("//This Script used " + (string)((16384 - llGetFreeMemory())/1024) + " kBytes");         
    }
}





... and outputs something like this:

[23:00]  Object: llSetPrimitiveParams([
[23:00]  Object: PRIM_FLEXIBLE, TRUE, 2.000000, 0.300000, 2.000000, 0.000000, 1.000000, <0.01000, 0.00000, 0.01000>, 
[23:00]  Object: PRIM_MATERIAL, PRIM_MATERIAL_WOOD, 
[23:00]  Object: PRIM_PHANTOM, TRUE, 
[23:00]  Object: PRIM_PHYSICS, FALSE, 
[23:00]  Object: PRIM_POINT_LIGHT, TRUE, <1.00000, 1.00000, 1.00000>, 1.000000, 10.000000, 0.750000, 
[23:00]  Object: PRIM_POSITION, <57.18748, 200.57619, 21.45186>, 
[23:00]  Object: PRIM_ROTATION, <0.00000, 0.00000, 0.00000, 1.00000>, 
[23:00]  Object: PRIM_SIZE, <0.76611, 0.76611, 0.76611>, 
[23:00]  Object: PRIM_TEMP_ON_REZ, FALSE, 
[23:00]  Object: PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_CIRCLE, <0.00000, 1.00000, 0.00000>, 0.099900, <0.00000, 0.00000, 0.00000>, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 
[23:00]  Object: PRIM_FULLBRIGHT, 0, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 1, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 2, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 3, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 4, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 5, TRUE, 
[23:00]  Object: PRIM_FULLBRIGHT, 6, TRUE, 
[23:00]  Object: PRIM_BUMP_SHINY, 0, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 1, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 2, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 3, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 4, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 5, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_BUMP_SHINY, 6, PRIM_SHINY_MEDIUM, PRIM_BUMP_CHECKER, 
[23:00]  Object: PRIM_COLOR, 0, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 1, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 2, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 3, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 4, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 5, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_COLOR, 6, <1.00000, 1.00000, 1.00000>, 1.000000, 
[23:00]  Object: PRIM_TEXGEN, 0, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 1, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 2, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 3, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 4, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 5, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXGEN, 6, PRIM_TEXGEN_PLANAR, 
[23:00]  Object: PRIM_TEXTURE, 0, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 1, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 2, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 3, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 4, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 5, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000, 
[23:00]  Object: PRIM_TEXTURE, 6, 89556747-24cb-43ed-920b-47caed15465f, <1.00000, 1.00000, 0.00000>, <0.00000, 0.00000, 0.00000>, 0.000000
[23:00]  Object: ]);


Anylyn Hax 15:58, 8 August 2007 (PDT)



View the issues Anylyn Hax has filed at jira.secondlife.com