Difference between revisions of "User:Jasper Flossberg"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL Header}} This single prim HUD is just a button that scrolls through nearby players names, photos and user key. Drop it in a prim and touch the prim and you are set to go. …")
 
 
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}


This single prim HUD is just a button that scrolls through nearby players names, photos and user key.
This is a KeyFrame Animator Script to simplify construction of keyframed animations.
Drop it in a prim and touch the prim and you are set to go.  Modify it to suit your particular use in another Hud, weapon, or whatever you want.
--[[User:Jasper Flossberg|Jasper Flossberg]]
<3
--[[User:Ackley Bing|Ackley Bing]]


<lsl>
<lsl>
// Basic Target Scanner HUD
integer channel=0;
// by Ackley Bing
integer MODE=0;  // 0 NonInit 1 Init 2 Run
//
list keys=[];
// Drop this in a prim and touch
vector last_pos;
rotation last_rot;


key HUDtarget;
vector start_pos;
integer HUDattachpoint=ATTACH_HUD_CENTER_1;
rotation start_rot;
integer senseindex;
key photoReq;


TargetInfo(key id)
update_loc()
{
{
     llSetText(llToLower(llGetDisplayName(id))+"\n"+(string)id, <0.0, 1.0, 0.0>, 1.0);
     last_pos=llGetPos();
     if ( id!=NULL_KEY )
     last_rot=llGetRot();
    {
        photoReq=llHTTPRequest("http://world.secondlife.com/resident/" + (string)id, [], "");
        llOwnerSay("Current Target: secondlife:///app/agent/" + (string)id + "/inspect " + (string)id );
    }
    else
    {
        llSetTexture("8dcd4a48-2d37-4909-9f78-f7a9eb4ef903", 0);
        llOwnerSay("No Target");
    }
}
}


Line 36: Line 24:
     state_entry()
     state_entry()
     {
     {
         llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);
         llSay(0, "Welcome to the KeyFrame Setter v1.0 by Jasper Flossberg");
        llListen(0,"",NULL_KEY,"");
    }
 
    touch_start(integer total_number)
    {
        channel=(integer)llFrand(4000000);
        llDialog(llDetectedKey(0),"Please choose option",["Init","Run","Export"],channel);
        llListen(channel,"",NULL_KEY,"");
     }
     }
     attach(key id)
     listen(integer channel, string name, key id, string message)
     {
     {
         if (id)
         if(message=="Init")
         {
         {
             llSetScale(<0.1, 0.15, 0.1>);
             llSay(0,"Intializing KeyFrame Setter");
             llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <2.0, 0.5, 1.0>, <0.0, 0.0, 0.0>, PRIM_ROT_LOCAL, <0.000000, -0.707107, 0.000000, 0.707107>, PRIM_COLOR, 0, <1.0,1.0,1.0>, 1.0, PRIM_COLOR, 1, <0.0,1.0,0.0>, 1.0, PRIM_COLOR, 3, <0.0,1.0,0.0>, 1.0, PRIM_COLOR, 2, <1.0,1.0,1.0>, 0.0, PRIM_COLOR, 4, <1.0,1.0,1.0>, 0.0]);
             llSetKeyframedMotion([],[]);
             llRotateTexture(270.0*DEG_TO_RAD,0);
             keys=[];
             HUDattachpoint=llGetAttached();
            update_loc();
             senseindex=0;
             start_pos=llGetPos();
             llSensor("", "", AGENT, 128, TWO_PI);
             start_rot=llGetRot();
             MODE=1;
 
         }
         }
    }
         if(llGetSubString(message,0,2)=="set")
    on_rez(integer param)
    {
         if ( !llGetAttached() ) llRequestPermissions(llGetOwner(),PERMISSION_ATTACH|PERMISSION_TAKE_CONTROLS);
    }
    touch_start(integer tsn)
    {
        if ( !llGetAttached() ) llRequestPermissions(llGetOwner(),PERMISSION_ATTACH|PERMISSION_TAKE_CONTROLS);
        senseindex=senseindex+(llDetectedTouchFace(0)==1)-(llDetectedTouchFace(0)==3);
        llSensor("", "", AGENT, 128, TWO_PI);
    }
    sensor(integer num)
    {
        senseindex=((senseindex<0)*(num-1))+((senseindex>=0)*(senseindex*(senseindex!=num)));
        HUDtarget=llDetectedKey(senseindex);
        TargetInfo(HUDtarget);
    }
    no_sensor()
    {
        senseindex=0;
        HUDtarget=NULL_KEY;
        TargetInfo(HUDtarget);
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        if( request_id == photoReq )
         {
         {
             string photoID;
             if(MODE==1)
            integer StartIndex=llSubStringIndex(body,"<title>");
            integer EndIndex=llSubStringIndex(body,"</title>");
            if( StartIndex!=-1)
             {
             {
                 integer tempIndex=llSubStringIndex(body,"imageid")+18;
                 string time=llList2String(llParseString2List(message,[" "],[]),1);
                 if(tempIndex>17)photoID=llGetSubString(body,tempIndex,tempIndex+35);
                 llSay(0,"Setting new KeyFrame with "+time);
                keys+=[llGetPos()-last_pos,ZERO_ROTATION*(llGetRot()/last_rot),(integer)time];
                update_loc();
             }
             }
            if ( photoID==NULL_KEY || photoID=="" ) photoID="8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
             
             llSetTexture(photoID, 0);
        }
        if(message=="Run")
        {
            MODE=2;
            llSetPrimitiveParams([PRIM_POSITION,start_pos,PRIM_ROTATION,start_rot]);
            llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]);
        }
        if(message=="Export")
        {
             llSay(0,(string)keys);
         }
         }
    }
    run_time_permissions(integer perms)
    {
        if ( perms & PERMISSION_ATTACH ) llAttachToAvatar(HUDattachpoint);
        if ( perms & PERMISSION_TAKE_CONTROLS ) llTakeControls(CONTROL_BACK, FALSE, TRUE); // required to allow script to continue to operate in 'no-script' areas and has to be activated before entering the 'no-script' area.
     }
     }
}
}
</lsl>
</lsl>

Latest revision as of 02:19, 29 April 2013

This is a KeyFrame Animator Script to simplify construction of keyframed animations. --Jasper Flossberg

<lsl> integer channel=0; integer MODE=0; // 0 NonInit 1 Init 2 Run list keys=[]; vector last_pos; rotation last_rot;

vector start_pos; rotation start_rot;

update_loc() {

   last_pos=llGetPos();
   last_rot=llGetRot();

}

default {

   state_entry()
   {
       llSay(0, "Welcome to the KeyFrame Setter v1.0 by Jasper Flossberg");
       llListen(0,"",NULL_KEY,"");
   }
   touch_start(integer total_number)
   {
       channel=(integer)llFrand(4000000);
       llDialog(llDetectedKey(0),"Please choose option",["Init","Run","Export"],channel);
       llListen(channel,"",NULL_KEY,"");
   }
   listen(integer channel, string name, key id, string message)
   {
       if(message=="Init")
       {
           llSay(0,"Intializing KeyFrame Setter");
           llSetKeyframedMotion([],[]);
           keys=[];
           update_loc();
           start_pos=llGetPos();
           start_rot=llGetRot();
           MODE=1;
       }
       if(llGetSubString(message,0,2)=="set")
       {
           if(MODE==1)
           {
               string time=llList2String(llParseString2List(message,[" "],[]),1);
               llSay(0,"Setting new KeyFrame with "+time);
               keys+=[llGetPos()-last_pos,ZERO_ROTATION*(llGetRot()/last_rot),(integer)time];
               update_loc();
           }
              
       }
       if(message=="Run")
       {
           MODE=2;
           llSetPrimitiveParams([PRIM_POSITION,start_pos,PRIM_ROTATION,start_rot]);
           llSetKeyframedMotion(keys,[KFM_MODE,KFM_LOOP]);
       }
       if(message=="Export")
       {
           llSay(0,(string)keys);
       }
   }

} </lsl>