User:Void Singer/Programs

From Second Life Wiki
< User:Void Singer
Revision as of 23:24, 28 May 2010 by Void Singer (talk | contribs) (minor changes)
Jump to navigation Jump to search

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.3 )//*/

/*//-- 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 !!!

//*/

//-- Stores owner key

key gKeyOwn;

//-- Stores Owner Based Channel

integer gIntChn;

//-- Stores User Defined Color

vector gColSav;

//-- Stores which color(s) to modify

integer gIdxPnl;

//-- Stores the link number of all linked prims with the same name

list gLstTgt;

//-- Stores Name of Product

string gStrPID = "v7-D Adv Color Picker v1.3";

//-- Stores buttons for the dialog

list gLstBtn = ["-1", "-8", "-64", "+1", "+8", "+64",

                   "Reset", "Done!", "Save",
                   "All Colors", "Red Only", "Green Only", "Blue Only"];
//-- Stores programatic values of buttons

list gLstVal = [-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>];
//-- builds the dialog to send to the owner

uDialog(){ //-- GetThe Current Color of this sets base in 0-255 range vector vColTmp = llGetColor( ALL_SIDES ) * 255; //-- build and send dialog to owner llDialog( gKeyOwn, gStrPID + "\n\nModifying " + llList2String( gLstBtn, gIdxPnl ) + "\n\nCurrent Values (0-255):\n" + "R:" + (string)llRound( vColTmp.x ) + ", G:" + (string)llRound( vColTmp.y ) + ", B:" + (string)llRound( vColTmp.z ) + " = #" + uFlt2Byt( (integer)vColTmp.x ) + uFlt2Byt( (integer)vColTmp.y ) + uFlt2Byt( (integer)vColTmp.z ), llDeleteSubList( gLstBtn, gIdxPnl, gIdxPnl ), gIntChn ); //-- set timeout to close listen llSetTimerEvent( 60.0 ); }

//-- convert float byte to hex byte

string uFlt2Byt( float vFltByt ){ integer vIntByt = llRound( vFltByt ); string vStrHex = "0123456789ABCDEF"; return llGetSubString( vStrHex, vIntByt >> 4, vIntByt >> 4 ) + llGetSubString( vStrHex, vIntByt & 15, vIntByt & 15 ); }

uSetCol( vector vColUse ){ //-- Clamp Color ranges vColUse = <(vColUse.x * (vColUse.x > 0.0) - 1.0) * (vColUse.x < 1.0) + 1.0, (vColUse.y * (vColUse.y > 0.0) - 1.0) * (vColUse.y < 1.0) + 1.0, (vColUse.z * (vColUse.z > 0.0) - 1.0) * (vColUse.z < 1.0) + 1.0>; //-- loop through all prims with our name and set them integer vIntTmp = gLstTgt != []; do{ llSetLinkColor( llList2Integer( gLstTgt, --vIntTmp ), vColUse, ALL_SIDES ); }while (vIntTmp); }


default{ state_entry(){ gKeyOwn = llGetOwner(); gIntChn = (integer)("0xF" + llGetSubString( (string)gKeyOwn, 1, 7 )); //-- get the target prim name from current prim string vStrTID = llGetObjectName(); //-- get the number of prims in the sets integer vIntTmp = llGetNumberOfPrims(); //-- Check all prims; store ones with our name do{ if (llGetLinkName( vIntTmp ) == vStrTID){ gLstTgt += (list)vIntTmp; } }while (~(--vIntTmp)); //-- avoid dumping the changed event if one is queued llSetTimerEvent( 0.01 ); }

//-- reset script to prevent errors from link or owner changes changed( integer vBitChg ){

if ((CHANGED_LINK

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.2f --//*/

/*//-- 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; /*//-- List 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 ); /*//-- Grab 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 + llGetRegionCorner()) + 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(){ if (gKeySec){ llOwnerSay( "Dataserver Response Timed Out, auto retry in " + (string)((integer)gFltTmt) + " seconds" ); gKeySec = ""; }else{ llResetScript(); } } }

state sReady{ state_entry(){ /*//-- Set The Initial Display --//*/ llSetText( llList2String( gLstLMs, gIdxTgt ), <1.0, 0.0, 0.0>, 1.0 ); llOwnerSay( "Ready" ); }

touch_end( integer vIntNul ){ /*//-- 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 != [])) ), <1.0, 0.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 ) - llGetRegionCorner(), ZERO_VECTOR ); } }

changed( integer vBitChg ){ if (CHANGED_INVENTORY & vBitChg){ /*//-- 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>

Return to top

Script (Small Code Version)

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

/*//-- 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 = (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 ); 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 + llGetRegionCorner(); llSetText( gStrLMN, <1.0, 0.0, 0.0>, 1.0 ); } }

touch_end( integer vIntNul ){ /*//-- Check if a prim named "prev" or "next" was touched --//*/ integer vIntTst = llSubStringIndex( "prevnext", llGetLinkName( llDetectedLinkNumber( 0 ) ) ); if (~vIntTst){ uUpdateLM( (vIntTst > 0) - (vIntTst == 0) ); /*//-- ((vIntTst > 0) - (vIntTst < 0)) same as: -1 for "prev", +1 for "next" --//*/ }else{ /*//-- Trigger map for any other touched prim in this object --//*/ llMapDestination( llGetRegionName(), gPosLoc - llGetRegionCorner(), ZERO_VECTOR ); } }

timer(){ /*//-- Make Sure Landmark didn't get deleted before trying to to read it again --//*/ if (INVENTORY_LANDMARK == llGetInventoryType( gStrLM )){ llOwnerSay( "Dataserver Response Timed Out. Unable To Change Destination; Trying Again" ); gKeySec = llRequestInventoryData( gStrLMN ); }else{ /*//-- Landmark no longer exists in inventory, set a safe default --//*/ uUpdateLM( 0 ); } } }

/*//-- 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>

Return to top

v7-D Advanced Visitor Greeter

Features:

  • Reduced Spam
  • Easily Modified
  • Multiple Configurations

Script

<lsl>/*//( v7-D Advanced Avatar Greeter v1.4.1 Annotated )//*/

/*//-- NOTE:

Remove Any Instances Of "(gLstAvs = []) + " Or "(gLstTms = []) + " When Compiling This
Script To MONO. They Are Provided For LSO Memory Conservation And Do Nothing In MONO

//*/

list gLstAvs; /*//-- List Of Avatars Keys Greeted --//*/ list vLstChk; /*//-- List Of Single Av Key Checked During Sensor Processing --//*/ integer vIdxLst; /*//-- Index Of Checked Item In List (reused) --//*/ integer gIntMax = 500; /*//-- Maximum Number of Names To Store --//*/

/*//-- Previous Code Line PreSet to Ease Removing Dynamic Memory Limitation Code --//*/
/*//-- Next Code Line  Belongs to Dynamic Memory Limitation Section --//*/

integer int_MEM = 1000; /*//-- memory to preserve for safety (Needs to be > ~700)--//*/

/*//-- Start Av Culling Section --//*/

integer gIntPrd = 172800; /*//-- Number Of Seconds After Detection To Store Av --//*/ integer vIntNow; /*//-- Integer To Store Current Time During Sensor Processing --//*/ list gLstTms; /*//-- List Of Most Recent Times Avs Were Greeted At --//*/ list vLstTmt; /*//-- List To Store Timeout During Sensor Processing --//*/

/*//-- End Av Culling Section --//*/

default{ state_entry(){ /*//-- Next Code Line Belongs To Dynamic Memory Limitation Section --//*/ gIntMax = int_MEM; /*//-- Override Max if Dynamic Memory Limitation is in use --//*/ llSensor( "", "", AGENT, 95.0, PI ); /*//-- Pre-Fire Sensor For Immediate Results --//*/ llSetTimerEvent( 30.0 ); /*//-- Sensor Repeat Frequency --//*/ }

timer(){ llSensor( "", "", AGENT, 95.0, PI ); /*//-- Look For Avatars --//*/ }

sensor( integer vIntTtl ){ /*//-- Save Current Timer to Now, Then Add Period and Save To Timeout--//*/ vLstTmt = (list)(gIntPrd + (vIntNow = llGetUnixTime())); /*//-- Previous Code Line Belongs to Av Culling Section --//*/ @Building;{ /*//-- Is This Av Already In Our List? --//*/ if (~(vIdxLst = llListFindList( gLstAvs, (vLstChk = (list)llDetectedKey( --vIntTtl )) ))){ /*//-- Delete The Old Entries & Add New Entries to Preserve Order --//*/ gLstAvs = llDeleteSubList( (gLstAvs = []) + gLstAvs, vIdxLst, vIdxLst ) + vLstChk; /*//-- Next Code Line Belongs to Av Culling Section --//*/ gLstTms = llDeleteSubList( (gLstTms = []) + gLstTms, vIdxLst, vIdxLst ) + vLstTmt; } else{ /*//-- Oo Goody, Hi New Av! Add Them To The Lists & Preserve Max List Size--//*/ llInstantMessage( (string)vLstChk, "Hello " + llDetectedName( vIntTtl ) ); gLstAvs = llList2List( (gLstAvs = []) + vLstChk + gLstAvs, 0, gIntMax ); /*//-- Next Code Line Belongs to Av Culling Section --//*/ gLstTms = llList2List( (gLstTms = []) + vLstTmt + gLstTms, 0, gIntMax ); } }if (vIntTtl) jump Building;

/*//-- Start Dynamic Memory Limitation Section --//*/ /*//-- Only lower Max List Size Once For Saftey --//*/ if (int_MEM == gIntMax){ /*//-- do we have plenty of room in the script? --//*/ if (int_MEM > llGetFreeMemory()){ /*//-- running out of room, set the Max list size lower --//*/ gIntMax = ~([] != gLstAvs); } } /*//-- End Dynamic Memory Limitation Section --//*/

/*//-- Start Av Culling Section --//*/ /*//-- do we have keys? --//*/ if (vIdxLst = llGetListLength( gLstTms )){ /*//-- Do Any Need Culled? --//*/ if (vIntNow > llList2Integer( gLstTms, --vIdxLst )){ /*//-- Find The Last Index that hasn't hit timeout status --//*/ @TheirBones; if (--vIdxLst) if (vIntNow > llList2Integer( gLstTms, vIdxLst )) jump TheirBones; /*//-- Thin the herd --//*/ gLstAvs = llList2List( (gLstAvs = []) + gLstAvs, 0, vIdxLst ); gLstTms = llList2List( (gLstTms = []) + gLstTms, 0, vIdxLst ); } } /*//-- End Av Culling Section --//*/ } }

/*//-- 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>

Return to top

Questions or Comments?

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