User:Darwin Recreant

From Second Life Wiki
Revision as of 01:53, 10 December 2008 by Darwin Recreant (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

About Me

Hi I'm Darwin Recreant. I reside in Israel and has been enjoying Second Life since March 2007. I co-own the College of Scripting Music and Science along with Keystoner March and Shera Beam. I'm an advanced scripter and currently open for any large project offers. I also give private lessons on scripting.

Feel free to contact me in-world.

Achievements

  • Contributed to the success of the College
  • Creator of the Anti-Griefer HUD
  • Creator of the DRUID Holodeck
  • Non-stop scripting development
    • Teleporters
    • Vendors
    • Anti-Griefing tools
    • Scripting tools (functions)
    • Useful HUD's of all sorts
  • Helper to dozens of newbie/intermediate scripters

My Wiki Articles

My Jira Reports

  • VWR-6493 - Momentary inaccuracy with llSetPos in linked objects
  • SVC-3449 - New function: llGetParcelAgents
  • MISC-969 - New Feature: Prim Animations - Less laggy, smoother, avatar like, animations on prims
  • SEC-230 - MONO: Script crashes sim

My Scripts

Find Screen Width

The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points. <lsl>default {

   touch_start(integer total_number)
   {
       vector scale = llGetScale();
       vector off_point = llGetLocalPos();
       vector face_pos = llDetectedTouchST(0);
       vector screen_pos = llDetectedTouchPos(0);
       
       float screen_width = ((face_pos.x-.5)*scale.y-off_point.y+screen_pos.y)*2;
       
       llOwnerSay((string)screen_width);
   }
}</lsl>

Color Picker

Script that converts hue/sat/lum to red/green/blue based on texture coordinates on a single prim and outputs the vector rgb.

Prim Setup

<lsl>default {

   state_entry()
   {
       llSetPrimitiveParams([
           PRIM_SIZE, <.5,.4,.1>, 
           PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_SQUARE, <0,1,0>, 0.0, <0,0,0>, <.8,1,0>, <.02,0,0>, 
           PRIM_TEXTURE, ALL_SIDES, (key)"5748decc-f629-461c-9a36-a35a221fe21f", <1,1,0>, <0,0,0>, 0.0, 
           PRIM_TEXTURE, 0, (key)"404e4461-8a22-fbf7-7652-4b81dc7da325", <1,1,0>, <0,0,0>, 0.0, 
           PRIM_TEXTURE, 2, (key)"01c02d68-dfb0-d907-7397-cba857c61144", <1,1,0>, <0,0,0>, -PI_BY_TWO]);
   }

} </lsl>

Color Picker

<lsl>float hue = 0.0; float lum = 0.5; float sat = 1.0;

integer start_face;

//hsl to rgb steps take from http://130.113.54.154/~monger/hsl-rgb.html vector hsl_to_rbg(float h, float s, float l) {

   vector rbg;
   float temp1;
   float temp2;
   
   if(l < .5)
       temp2 = l*(1.0+s);
   else
       temp2 = l+s-l*s;
   
   temp1 = l*2.0-temp2;
   
   float Rtemp3 = h+1.0/3.0;
   if(Rtemp3 < 0.0)
       Rtemp3 = Rtemp3+1.0;
   else if(Rtemp3 > 1.0)
       Rtemp3 = Rtemp3-1.0;
       
   float Gtemp3 = h;
   if(Gtemp3 < 0.0)
       Gtemp3 = Gtemp3+1.0;
   else if(Gtemp3 > 1.0)
       Gtemp3 = Gtemp3-1.0;
       
   float Btemp3 = h-1.0/3.0;
   if(Btemp3 < 0.0)
       Btemp3 = Btemp3+1.0;
   else if(Btemp3 > 1.0)
       Btemp3 = Btemp3-1.0;
       
   if(6.0*Rtemp3 < 1.0)
       rbg.x = temp1+(temp2-temp1)*6.0*Rtemp3;
   else if(2.0*Rtemp3 < 1.0)
       rbg.x = temp2;
   else if(3.0*Rtemp3 < 2.0)
       rbg.x = temp1+(temp2-temp1)*((2.0/3.0)-Rtemp3)*6.0;
   else
       rbg.x = temp1;
       
   if(6.0*Gtemp3 < 1.0)
       rbg.y = temp1+(temp2-temp1)*6.0*Gtemp3;
   else if(2.0*Gtemp3 < 1.0)
       rbg.y = temp2;
   else if(3.0*Gtemp3 < 2.0)
       rbg.y = temp1+(temp2-temp1)*((2.0/3.0)-Gtemp3)*6.0;
   else
       rbg.y = temp1;
       
   if(6.0*Btemp3 < 1.0)
       rbg.z = temp1+(temp2-temp1)*6.0*Btemp3;
   else if(2.0*Btemp3 < 1.0)
       rbg.z = temp2;
   else if(3.0*Btemp3 < 2.0)
       rbg.z = temp1+(temp2-temp1)*((2.0/3.0)-Btemp3)*6.0;
   else
       rbg.z = temp1;
   return rbg;

}

default {

   touch_start(integer total_number)
   {
       start_face = llDetectedTouchFace(0);
       if(start_face == 4)
           llOwnerSay((string)hsl_to_rbg(hue, sat, lum));
   }
   
   touch(integer total_number)
   {
       vector st = llDetectedTouchST(0);
       integer face = llDetectedTouchFace(0);
       if(start_face != face) return;
       if(face == 0)
       {
           sat = st.y;
           hue = st.x;
           llSetColor(hsl_to_rbg(hue, sat, lum), 4);
       }
       else if(face == 2)
       {
           lum = st.x;
           llSetColor(hsl_to_rbg(hue, sat, lum), 4);
       }
   }

}

</lsl>

Date Difference

Finds the difference in days between two dates. Dates are used in the format yyyy-mm-dd <lsl>integer dateDiff(string date1, string date2) {

   list months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
   
   integer year1 = (integer)llGetSubString(date1, 0, 3);
   integer month1 = (integer)llGetSubString(date1, 5, 6);
   integer day1 = (integer)llGetSubString(date1, 8, 9);
   
   integer year2 = (integer)llGetSubString(date2, 0, 3);
   integer month2 = (integer)llGetSubString(date2, 5, 6);
   integer day2 = (integer)llGetSubString(date2, 8, 9);
   
   integer daysDiff;
   integer i;
   
   integer yeardays1;
   for(i=0; i<month1-1; i++)
       yeardays1 += llList2Integer(months, i);
   yeardays1 += day1;
   
   integer yeardays2;
   for(i=0; i<month2-1; i++)
       yeardays2 += llList2Integer(months, i);
   yeardays2 += day2;
   
   daysDiff = yeardays2 - yeardays1 + 365*(year2-year1);
   
   return daysDiff;
}</lsl>

UV Button Maker

The following scripts are tools to making your own uv button setup for a texture in a hud or for any multi-button texture. First script is for getting the button coordinates which are used in the second script (detected_button) which returns the button number pressed.

Get Coordinates

<lsl>integer start_face; vector start_uv;

default {

  touch_start(integer s)
  {
      start_face = llDetectedTouchFace(0);
      start_uv = llDetectedTouchUV(0);
      start_uv.x += -(integer)start_uv.x - (start_uv.x < 0);
      start_uv.y += -(integer)start_uv.y - (start_uv.y < 0);
  }
  touch(integer s)
  {
     if(llDetectedTouchFace(0) == start_face)
     {
        vector new_uv = llDetectedTouchUV(0);
        new_uv.x -= (integer)new_uv.x - (new_uv.x < 0);
        new_uv.y -= (integer)new_uv.y - (new_uv.y < 0);
        llSetText((string)start_uv+"