Difference between revisions of "User:Void Singer/Programs"

From Second Life Wiki
Jump to navigation Jump to search
m (new free to use script, yay)
m (New Freebies)
Line 1: Line 1:
<div style="float:right;">__TOC__</div>
<div style="float:right;">__TOC__</div>
<div id="box">
{{void-box
== [[User:Void_Singer|Return to Void Singers user page]] ==
|title=[[User:Void_Singer|Return to Void Singers user page]]
</div>
}}


<div id="box">
{{void-box
== v7-D Adv Color Picker v1.2 ==
|title=v7-D Enh. Color Picker
<div  style="padding: 0.5em">
|content=
=== Features: ===
=== Features: ===
* Dialog driven.
* Dialog driven.
Line 13: Line 13:
* Colors multiple linked prims at once.
* Colors multiple linked prims at once.
* Compatible with standard color picker displays.
* Compatible with standard color picker displays.
=== Script ===
=== Script ===
<lsl> /// v7-D Adv Color Picker v1.2 license Text - DO NOT REMOVE! ///
<lsl> /*//-- v7-D Enh. Color Picker v1.2 --//*/
//                                                            //
//      This script is provided freely by Void Singer          //
//      https://wiki.secondlife.com/wiki/User:Void_Singer      //
//      under the Creative Commons CC-BY license found at      //
//      http://creativecommons.org/licenses/by/3.0/            //
//      A plain text readable copy of this notice must be      //
//      made available with all usages.                        //
//                                                            //
////////////////////////////////////////////////////////////////


//-- That means you can use, copy, modify, give away, or
/*//-- IMPORTANT NOTE
//-- even sell the code; so long as you attribute it with
This Script MUST be
//-- the above license text that may be read by the user.
placed in one  of the
prims it is going to
//--// ~ IMPORTANT NOTE ~ //--//
modify or it will not
//                            //
work properly!
//  This Script MUST be       //
 
//  placed in one  of the     //
All Prims that are to
//  prims it is going to     //
be modified at the
//  modify or it will not     //
same time MUST have
//  work properly!           //
the SAME NAME !!!
//                            //
//*/
//  All Prims that are to     //
//  to modified at the       //
//  same time MUST have       //
//  the SAME NAME !!!         //
//                             //
////////////////////////////////


key    gKeyOwner;
key    gKeyOwner;
Line 192: Line 178:
     }
     }
   }
   }
}</lsl>
}
/*//-- License Text:
Free to copy, use, modify, distribute, or sell, with attribution.
  (C)2009 (CC-BY) [http://creativecommons.org/licenses/by/3.0]
  Void Singer [https://wiki.secondlife.com/wiki/User:Void_Singer]
All usages must contain a plain text copy of the previous 2 lines.
//*/</lsl>
:[[User:Void_Singer/Programs#Return_to_Void_Singers_user_page|Return to top]]
}}
 
{{void-box
|title=v7-D Enh. Landmark-2-Map
|content=
=== Features ===
* Next/Pevious Landmark Buttons.
* Hovertext Display of Landmark Name.
* Auto-Wrapping of Next/Previous Targets.
* Works as a HUD or a Free-Standing Object.
* Warning on No Landmarks Found (with safe default).
 
=== Script (Fast Response Version) ===
<lsl>/*//-- v7-D Enhanced Landmark Mapper v1.1f --//*/
 
/*//-- Requirements:
3 linked Prims (minimum)
1 Named "prev" (this will be your previous landmark button)
1 Named "next" (this will be your next landmark button)
any other prim in the object will trigger the map destination for the
currently displayed Landmark name. Recommended to rename landmarks.
//*/
 
integer gIdxTgt; /*//-- Index of Target --//*/
list    gLstLMs; /*//-- List of Landmarks --//*/
list    gLstLoc; /*//-- Listt of Locations--//*/
 
key    gKeySec;      /*//-- Key for Security checking dataserver calls --//*/
float  gFltTmt = 5.0; /*//-- Float for Timeout (dataserver calls & inventory changes) --//*/
 
default{
  state_entry(){
    llOwnerSay( "Rebuilding Database" );
    gIdxTgt = llGetInventoryNumber( INVENTORY_LANDMARK );
    /*//-- Gab Landmark Names For Display --//*/
    if (gIdxTgt){
      while(gIdxTgt){
        gLstLMs = (list)llGetInventoryName( INVENTORY_LANDMARK, --gIdxTgt ) + gLstLMs;
      }
      /*//-- Get First LM Location --//*/
      gKeySec = llRequestInventoryData( llList2String( gLstLMs, gIdxTgt = (gLstLMs != []) - 1 ) );
      /*//-- (gLstLMs != []) == llGetListLength( gLstLMs ) --//*/
      /*//-- negative indices would've been nice if they were supported by the Req.Inv.Data call --//*/
      llSetTimerEvent( gFltTmt );
    }
    else{
      gLstLMs = (list)"Out Of Order, No Landmarks Present";
      gLstLoc = (list)<128.0, 128.0, 0.0>;
      state sReady;
    }
  }
 
  dataserver( key vKeySec, string vStrLoc ){
    /*//-- verify we're getting our data, not another scripts --//*/
    if (gKeySec == vKeySec){
      /*//-- Store Location Vector --//*/
      gLstLoc = (list)((vector)vStrLoc) + gLstLoc;
      if (gIdxTgt){
        /*//-- Get Next LM Location --//*/
        gKeySec = llRequestInventoryData( llList2String( gLstLMs, --gIdxTgt ) );
        llSetTimerEvent( gFltTmt );
      }
      else{
        /*//-- Clear Timeout Because Timers Cross States --//*/
        llSetTimerEvent( 0.0 );
        state sReady;
      }
    }
  }
 
  timer(){
    llOwnerSay( "Dataserver Response Timed Out, auto retry in " + (string)((integer)gFltTmt) + " seconds" );
    llSleep( gFltTmt );
    llResetScript();
  }
 
  state_exit(){
    /*//-- Set The Initial Display --//*/
    llSetText( llList2String( gLstLMs, gIdxTgt ), <1.0, 0.0, 0.0>, 1.0 );
    llOwnerSay( "Ready" );
  }
}
 
state sReady{
  touch_start( integer vInt ){
    /*//-- Check if a prim named "prev" or "next" was touched --//*/
    integer vIntTst = llSubStringIndex( "prevnext", llGetLinkName( llDetectedLinkNumber( 0 ) ) );
    if (~vIntTst){
      /*//-- Update Index Target --//*/
      gIdxTgt += ((vIntTst > 0) - (vIntTst < 0));
      /*//-- ((vIntTst > 0) - (vIntTst < 0)) same as: -1 for "prev", +1 for "next" --//*/
     
      /*//-- Update Display --//*/
      llSetText( llList2String( gLstLMs, (gIdxTgt %= (gLstLMs != [])) ), <0.0, 1.0, 0.0>, 1.0 );
      /*//-- (gLstLMs != []) == llGetListLength( gLstLMs ) --//*/
      /*//-- "gInCnt %= " allows us to wrap our references so they don't go out of range --//*/
    }
    else{
      /*//-- Trigger map for any other touched prim in this object --//*/
      llMapDestination( llGetRegionName(), llList2Vector( gLstLoc, gIdxTgt ), ZERO_VECTOR );
    }
  }
 
  changed( integer vBitChg ){
    if (vBitChg & CHANGED_INVENTORY){
      /*//-- give the user more time to add new LMs before we recompile our database lists. --//*/
      /*//-- We could check the count too, but don't in case the change was a change of name --//*/
      llSetTimerEvent( gFltTmt );
    }
  }
 
  timer(){
    llResetScript();
  }
}
 
/*//-- License Text:
Free to copy, use, modify, distribute, or sell, with attribution.
  (C)2009 (CC-BY) [http://creativecommons.org/licenses/by/3.0]
  Void Singer [https://wiki.secondlife.com/wiki/User:Void_Singer]
All usages must contain a plain text copy of the previous 2 lines.
//*/</lsl>
:[[User:Void_Singer/Programs#Return_to_Void_Singers_user_page|Return to top]]
 
=== Script (Small Code Version) ===
<lsl>/*//-- v7-D Enhanced Landmark Mapper v1.1s --//*/
 
/*//-- Requirements:
3 linked Prims (minimum)
1 Named "prev" (this will be your previous landmark button)
1 Named "next" (this will be your next landmark button)
any other prim in the object will trigger the map destination for the
currently displayed Landmark name. Recommended to rename landmarks.
//*/
integer gIdxTgt; /*//-- Index of Target LM --//*/
string  gStrLMN; /*//-- String of Landmark Name --//*/
vector  gPosLoc; /*//-- Position of Location --//*/
key    gKeySec; /*//-- Key for Security checking dataserver calls --//*/
 
uUpdateLM( integer vIntCng ){
  integer vIntCnt = llGetInventoryNumber( INVENTORY_LANDMARK );
  if (vIntCnt){
    gIdxTgt = gIdxTgt = (vIntCnt + (gIdxTgt + vIntCng)) % vIntCnt;
    /*//-- " + vIntCnt" correct for positive index needed by Req.Inv.Dat. --//*/
    /*//-- " % vIntCnt" range limit for current LM count --//*/
    gStrLMN = llGetInventoryName( INVENTORY_LANDMARK, gIdxTgt *= (gIdxTgt >= 0) );
    /*//-- (gIdxTgt >= 0) to protect against mass deletions of LMs enabling negative indices --//*/
    gKeySec = llRequestInventoryData( gStrLMN );
    llSetTimerEvent( 5.0 );
  }
  else{
    /*//-- Uh Oh, set a default of current sim, center, ground level --//*/
    llSetText( "Out Of Order, No Landmarks Present", <1.0, 0.0, 0.0>, 1.0 );
    gPosLoc = <128.0, 128.0, 0.0>;
  }
}
 
default{
  state_entry(){
    uUpdateLM( 0 );
  }
 
  dataserver( key vKeySec, string vStrLoc ){
    /*//-- verify we're getting our data, not another scripts --//*/
    if (gKeySec == vKeySec){
      /*//-- Clear the timeout --//*/
      llSetTimerEvent( 0.0 );
      /*//-- Store/Display New Target --//*/
      gPosLoc = (vector)vStrLoc;
      llSetText( gStrLMN, <1.0, 0.0, 0.0>, 1.0 );
    }
  }
 
  touch_start( integer vInt ){
    /*//-- Check if a prim named "prev" or "next" was touched --//*/
    integer vIntTst = llSubStringIndex( "prevnext", llGetLinkName( llDetectedLinkNumber( 0 ) ) );
    if (~vIntTst){
      uUpdateLM( (vIntTst > 0) - (vIntTst == 0) );
    }
    else{
      /*//-- Trigger map for any other touched prim in this object --//*/
      llMapDestination( llGetRegionName(), gPosLoc, ZERO_VECTOR );
    }
  }
 
  timer(){
    llOwnerSay( "Dataserver Response Timed Out. Unable To Change Destination; Try Again In A Moment" );
    /*//-- Clear the key so we don't update when it might interfere with a user --//*/
    gKeySec = "";
  }
}
 
/*//-- License Text:
Free to copy, use, modify, distribute, or sell, with attribution.
  (C)2009 (CC-BY) [http://creativecommons.org/licenses/by/3.0]
  Void Singer [https://wiki.secondlife.com/wiki/User:Void_Singer]
All usages must contain a plain text copy of the previous 2 lines.
//*/</lsl>
:[[User:Void_Singer/Programs#Return_to_Void_Singers_user_page|Return to top]]
:[[User:Void_Singer/Programs#Return_to_Void_Singers_user_page|Return to top]]
</div></div>
}}


<div id="box">
{{void-box
== Questions/Comments? ==
|title=Questions or Comments?
<div style="padding: 0.5em">
|content=
Feel free to leave me a note on my [[User_talk:Void_Singer|User Talk]] page.
Feel free to leave me a note on my [[User_talk:Void_Singer|User Talk]] page.
</div></div>
}}

Revision as of 00:07, 13 June 2009

v7-D Enh. Color Picker

Features:

  • Dialog driven.
  • Save and Recall.
  • Full 16 million+ colors.
  • Colors multiple linked prims at once.
  • Compatible with standard color picker displays.

Script

<lsl> /*//-- v7-D Enh. Color Picker v1.2 --//*/

/*//-- IMPORTANT NOTE

This Script MUST be
placed in one  of the
prims it is going to
modify or it will not
work properly!
All Prims that are to
be modified at the
same time MUST have
the SAME NAME !!!

//*/

key gKeyOwner; integer gIdxPanel; integer gChnDialog; list gLstTargets; integer gIntTargets; vector gColDefault = <0.0, 0.0, 0.0>; string gStrProduct = "v7-D Adv Color Picker v1.2"; list gLstButtons = ["-1", "-8", "-64", "+1", "+8", "+64",

                      "Recall", "Done!", "Save",
                      "All Colors", "Red Only", "Green Only", "Blue Only"];

list gLstBValues = [-0.003922, -0.031373, -0.250980, 0.003922, 0.031373, 0.250980,

                      <1.0, 1.0, 1.0>, <1.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 1.0>];


fColorDialog(){

 vector vColTemp = llGetColor( ALL_SIDES ) * 255;
  //-- build the dialog to send
 llDialog( gKeyOwner,
           gStrProduct + "\n\nModifying "
           + llList2String( gLstButtons, gIdxPanel )
           + "\n\nCurrent Values (0-255):\n"
           + "R:" + (string)llRound( vColTemp.x )
           + ", G:" + (string)llRound( vColTemp.y )
           + ", B:" + (string)llRound( vColTemp.z )
           + " = #" + fFloat2HexStr( vColTemp.x )
           + fFloat2HexStr( vColTemp.y )
           + fFloat2HexStr( vColTemp.x ),
           llDeleteSubList( gLstButtons, gIdxPanel, gIdxPanel ),
           gChnDialog );
 llSetTimerEvent( 45.0 );

}

string fFloat2HexStr( float vFltInput ){

 integer vBitInput = llRound( vFltInput );
 string  vStrValue = "0123456789ABCDEF";
 return llGetSubString( vStrValue, gIntTargets = vBitInput / 16, gIntTargets )
        + llGetSubString( vStrValue, gIntTargets = vBitInput % 16, gIntTargets );

}

fSetColor( vector vColUse ){

  //-- loop through target list of linked prims
 gIntTargets = gLstTargets != [];
 @Loop;
   llSetLinkColor( llList2Integer( gLstTargets, --gIntTargets ), vColUse, ALL_SIDES );
 if (gIntTargets) jump Loop;

}


default{

 state_entry(){
   gKeyOwner = llGetOwner();
   gChnDialog = (integer)("0xF" + llGetSubString( gKeyOwner, 1, 7 ));
   string  vStrTargetID = llGetObjectName();
   gIntTargets = llGetNumberOfPrims();
   @Loop;
     if (llGetLinkName( gIntTargets ) == vStrTargetID){
         gLstTargets += (list)gIntTargets;
     }
   if (~(--gIntTargets)) jump Loop;
   state sReady;
 }
 changed( integer vBitChanges ){
if ((CHANGED_OWNER

v7-D Enh. Landmark-2-Map

Features

  • Next/Pevious Landmark Buttons.
  • Hovertext Display of Landmark Name.
  • Auto-Wrapping of Next/Previous Targets.
  • Works as a HUD or a Free-Standing Object.
  • Warning on No Landmarks Found (with safe default).

Script (Fast Response Version)

<lsl>/*//-- v7-D Enhanced Landmark Mapper v1.1f --//*/

/*//-- Requirements:

3 linked Prims (minimum)
1 Named "prev" (this will be your previous landmark button)
1 Named "next" (this will be your next landmark button)
any other prim in the object will trigger the map destination for the
currently displayed Landmark name. Recommended to rename landmarks.

//*/

integer gIdxTgt; /*//-- Index of Target --//*/ list gLstLMs; /*//-- List of Landmarks --//*/ list gLstLoc; /*//-- Listt of Locations--//*/

key gKeySec; /*//-- Key for Security checking dataserver calls --//*/ float gFltTmt = 5.0; /*//-- Float for Timeout (dataserver calls & inventory changes) --//*/

default{

 state_entry(){
   llOwnerSay( "Rebuilding Database" );
   gIdxTgt = llGetInventoryNumber( INVENTORY_LANDMARK );
    /*//-- Gab Landmark Names For Display --//*/
   if (gIdxTgt){
     while(gIdxTgt){
       gLstLMs = (list)llGetInventoryName( INVENTORY_LANDMARK, --gIdxTgt ) + gLstLMs;
     }
      /*//-- Get First LM Location --//*/
     gKeySec = llRequestInventoryData( llList2String( gLstLMs, gIdxTgt = (gLstLMs != []) - 1 ) );
      /*//-- (gLstLMs != []) == llGetListLength( gLstLMs ) --//*/
      /*//-- negative indices would've been nice if they were supported by the Req.Inv.Data call --//*/
     llSetTimerEvent( gFltTmt );
   }
   else{
     gLstLMs = (list)"Out Of Order, No Landmarks Present";
     gLstLoc = (list)<128.0, 128.0, 0.0>;
     state sReady;
   }
 }
 
 dataserver( key vKeySec, string vStrLoc ){
    /*//-- verify we're getting our data, not another scripts --//*/
   if (gKeySec == vKeySec){
      /*//-- Store Location Vector --//*/
     gLstLoc = (list)((vector)vStrLoc) + gLstLoc;
     if (gIdxTgt){
        /*//-- Get Next LM Location --//*/
       gKeySec = llRequestInventoryData( llList2String( gLstLMs, --gIdxTgt ) );
       llSetTimerEvent( gFltTmt );
     }
     else{
        /*//-- Clear Timeout Because Timers Cross States --//*/
       llSetTimerEvent( 0.0 );
       state sReady;
     }
   }
 }
 
 timer(){
   llOwnerSay( "Dataserver Response Timed Out, auto retry in " + (string)((integer)gFltTmt) + " seconds" );
   llSleep( gFltTmt );
   llResetScript();
 }
 
 state_exit(){
    /*//-- Set The Initial Display --//*/
   llSetText( llList2String( gLstLMs, gIdxTgt ), <1.0, 0.0, 0.0>, 1.0 );
   llOwnerSay( "Ready" );
 }

}

state sReady{

 touch_start( integer vInt ){
    /*//-- Check if a prim named "prev" or "next" was touched --//*/
   integer vIntTst = llSubStringIndex( "prevnext", llGetLinkName( llDetectedLinkNumber( 0 ) ) );
   if (~vIntTst){
      /*//-- Update Index Target --//*/
     gIdxTgt += ((vIntTst > 0) - (vIntTst < 0));
      /*//-- ((vIntTst > 0) - (vIntTst < 0)) same as: -1 for "prev", +1 for "next" --//*/
     
      /*//-- Update Display --//*/
     llSetText( llList2String( gLstLMs, (gIdxTgt %= (gLstLMs != [])) ), <0.0, 1.0, 0.0>, 1.0 );
      /*//-- (gLstLMs != []) == llGetListLength( gLstLMs ) --//*/
      /*//-- "gInCnt %= " allows us to wrap our references so they don't go out of range --//*/
   }
   else{
      /*//-- Trigger map for any other touched prim in this object --//*/
     llMapDestination( llGetRegionName(), llList2Vector( gLstLoc, gIdxTgt ), ZERO_VECTOR );
   }
 }
 
 changed( integer vBitChg ){
   if (vBitChg & CHANGED_INVENTORY){
      /*//-- give the user more time to add new LMs before we recompile our database lists. --//*/
      /*//-- We could check the count too, but don't in case the change was a change of name --//*/
     llSetTimerEvent( gFltTmt );
   }
 }
 
 timer(){
   llResetScript();
 }

}

/*//-- License Text:

Free to copy, use, modify, distribute, or sell, with attribution.
  (C)2009 (CC-BY) [1]
 Void Singer [2]
All usages must contain a plain text copy of the previous 2 lines.

//*/</lsl>

Return to top

Script (Small Code Version)

<lsl>/*//-- v7-D Enhanced Landmark Mapper v1.1s --//*/

/*//-- Requirements:

3 linked Prims (minimum)
1 Named "prev" (this will be your previous landmark button)
1 Named "next" (this will be your next landmark button)
any other prim in the object will trigger the map destination for the
currently displayed Landmark name. Recommended to rename landmarks.

//*/

integer gIdxTgt; /*//-- Index of Target LM --//*/ string gStrLMN; /*//-- String of Landmark Name --//*/ vector gPosLoc; /*//-- Position of Location --//*/ key gKeySec; /*//-- Key for Security checking dataserver calls --//*/

uUpdateLM( integer vIntCng ){

 integer vIntCnt = llGetInventoryNumber( INVENTORY_LANDMARK );
 if (vIntCnt){
   gIdxTgt = gIdxTgt = (vIntCnt + (gIdxTgt + vIntCng)) % vIntCnt;
    /*//-- " + vIntCnt" correct for positive index needed by Req.Inv.Dat. --//*/
    /*//-- " % vIntCnt" range limit for current LM count --//*/
   gStrLMN = llGetInventoryName( INVENTORY_LANDMARK, gIdxTgt *= (gIdxTgt >= 0) );
    /*//-- (gIdxTgt >= 0) to protect against mass deletions of LMs enabling negative indices --//*/
   gKeySec = llRequestInventoryData( gStrLMN );
   llSetTimerEvent( 5.0 );
 }
 else{
    /*//-- Uh Oh, set a default of current sim, center, ground level --//*/
   llSetText( "Out Of Order, No Landmarks Present", <1.0, 0.0, 0.0>, 1.0 );
   gPosLoc = <128.0, 128.0, 0.0>;
 }

}

default{

 state_entry(){
   uUpdateLM( 0 );
 }
 
 dataserver( key vKeySec, string vStrLoc ){
    /*//-- verify we're getting our data, not another scripts --//*/
   if (gKeySec == vKeySec){
      /*//-- Clear the timeout --//*/
     llSetTimerEvent( 0.0 );
      /*//-- Store/Display New Target --//*/
     gPosLoc = (vector)vStrLoc;
     llSetText( gStrLMN, <1.0, 0.0, 0.0>, 1.0 );
   }
 }
 
 touch_start( integer vInt ){
    /*//-- Check if a prim named "prev" or "next" was touched --//*/
   integer vIntTst = llSubStringIndex( "prevnext", llGetLinkName( llDetectedLinkNumber( 0 ) ) );
   if (~vIntTst){
     uUpdateLM( (vIntTst > 0) - (vIntTst == 0) );
   }
   else{
      /*//-- Trigger map for any other touched prim in this object --//*/
     llMapDestination( llGetRegionName(), gPosLoc, ZERO_VECTOR );
   }
 }
 
 timer(){
   llOwnerSay( "Dataserver Response Timed Out. Unable To Change Destination; Try Again In A Moment" );
    /*//-- Clear the key so we don't update when it might interfere with a user --//*/
   gKeySec = "";
 }

}

/*//-- License Text:

Free to copy, use, modify, distribute, or sell, with attribution.
  (C)2009 (CC-BY) [3]
 Void Singer [4]
All usages must contain a plain text copy of the previous 2 lines.

//*/</lsl>

Return to top

Questions or Comments?

Feel free to leave me a note on my User Talk page.