User:Zai Lynch/Sandbox/LSL Goodies
IntroSo just for the record: I'm a complete LSL n00b. So don't expect much from this page. 'Cause I love the Open Source concept, I'd like to share some of my scripts with other SL Residents =)
Simple CountdownThis script displays a hovering countdown above the item it's placed in.
llSetText(TEXT+"\n"+(string)(SECONDS/86400)+" days, " +(string)((SECONDS%86400)/3600)+" hours, " +(string)(((SECONDS%86400)%3600)/60)+" minutes, " +(string)(((SECONDS%86400)%3600)%60)+ "seconds.",COLOR,1); }
default { state_entry() { SECONDS = SECONDS + MINUTES * 60 + HOURS * 3600 + DAYS * 86400; llSetTimerEvent(1); countdown(); } timer() { if (SECONDS > 0) { SECONDS = SECONDS - 1; countdown(); } else { llSetText(FINISHED, COLOR,1); llSetTimerEvent(0); } } } </lsl>
Basic Notecard-ReaderThis script reads notecards placed in the same prim as the script itself. <lsl> ////////////////////////////////////////////////////// // // // Basic Notecard-Reader // // released under // // Creative Commons Attribution-Share Alike 3.0 // // by Zai Lynch // // // //////////////////////////////////////////////////////
integer CHANNEL = 2130214; list MENU = ["Forward", "Backward", "Load", "Play", "Stop", "Time"]; // Variables list gMenuNC; integer gLine = 0; integer gTime = 5; string gNC = "";
integer i; integer n = llGetInventoryNumber(INVENTORY_NOTECARD); string name; gMenuNC = []; if (n > 0) { for (i=0; i<n; i++) { name = llGetInventoryName(INVENTORY_NOTECARD, i); if (llStringLength(name) < 25) gMenuNC = gMenuNC + [name]; else { llSay(0, "Name: "+name + " is to long."); llRemoveInventory(name); llSay(0, "Notecard removed."); } } } if (gNC == "") gNC=llGetInventoryName(INVENTORY_NOTECARD,0); }
default { state_entry() { zlGenerateList(); llListen(CHANNEL, "", llGetOwner(), ""); llListen(CHANNEL+1, "", llGetOwner(), ""); } on_rez(integer start_param) { llResetScript(); } changed(integer change) { if (change == CHANGED_INVENTORY) zlGenerateList(); } touch_start(integer num) { if (llDetectedKey(0) == llGetOwner()) llDialog(llGetOwner()," ",MENU,CHANNEL); } listen(integer cha, string name, key id, string msg) { if (cha == CHANNEL) { if (msg == "Stop") { llSetTimerEvent(0); llDialog(llGetOwner()," ",MENU,CHANNEL); } if (msg == "Play") { llSetTimerEvent(gTime); llGetNotecardLine(gNC, gLine); llDialog(llGetOwner()," ",MENU,CHANNEL); } if (msg == "Forward") { gLine = gLine + 1; llGetNotecardLine(gNC, gLine); llDialog(llGetOwner()," ",MENU,CHANNEL); llSetTimerEvent(0); } if ((msg == "Backward") && (gLine > 0)) { gLine = gLine - 1; llGetNotecardLine(gNC, gLine); llDialog(llGetOwner()," ",MENU,CHANNEL); llSetTimerEvent(0); } if (msg == "Load") llDialog(llGetOwner(), " ", gMenuNC, CHANNEL+1); if (msg == "Time") state listening; } if (cha == (CHANNEL+1)) { gNC = msg; gLine = 0; llDialog(llGetOwner()," ",MENU,CHANNEL); } } timer() { gLine = gLine+1; llGetNotecardLine(gNC, gLine); } dataserver(key qid, string data) { llSay(0, data); } state_exit() { llSetTimerEvent(0); } } state listening { state_entry() { llSetTimerEvent(30); llListen(0, "", llGetOwner(), ""); llSay(0,"Please tell me the desired updatetime in seconds."); } listen(integer cha, string name, key id, string msg) { gTime = (integer)msg; llSay(0, "Time set."); state default; } timer() { llSay(0,"Sorry, the request timed out."); state default; } state_exit() { llSetTimerEvent(0); llDialog(llGetOwner()," ",MENU,CHANNEL); } } </lsl>
Teleport via MapSet the description of the prim this script is attached to, to: SIMNAME/X/Y/Z <lsl> ////////////////////////////////////////////////////// // // // Teleport via Map // // released under // // Creative Commons Attribution-Share Alike 3.0 // // by Zai Lynch // // // ////////////////////////////////////////////////////// string simname; vector pos; integer touchStartTime;
init() { if (llGetObjectDesc() != "") { string desc = llGetObjectDesc(); simname = llGetSubString(desc,0,llSubStringIndex(desc,"/")-1); desc = llGetSubString(desc,llSubStringIndex(desc,"/")+1,llStringLength(desc)+1); integer x = (integer)llGetSubString(desc,0,llSubStringIndex(desc,"/")-1); desc = llGetSubString(desc,llSubStringIndex(desc,"/")+1,llStringLength(desc)+1); integer y = (integer)llGetSubString(desc,0,llSubStringIndex(desc,"/")-1); desc = llGetSubString(desc,llSubStringIndex(desc,"/")+1,llStringLength(desc)+1); integer z = (integer)llGetSubString(desc,0,llStringLength(desc)-1); pos = <x,y,z>; } else { simname="Omidyar"; pos=<130,86,200>; } }
state_entry() { init(); } touch_start(integer num_detected) { touchStartTime = llGetUnixTime(); } touch_end(integer num_detected) { if (llGetUnixTime() > touchStartTime + 4) { llSay(0,"Resetting..."); init(); } else llMapDestination(simname, pos, <1,1,1> ); } } </lsl>
BuzzerThis script is supposed to be used during meetings so a speaker isn't interrupted by questions while people can still indicate that they would like to speak. Up to 8 people might leave their indication by clicking the item where the script is attached to. Every name will only be listed once. Click and hold it clicked for more than 3 seconds to delete the upmost name. <lsl> ////////////////////////////////////////////////////// // // // zlBuzzer // // released under // // Creative Commons Attribution-Share Alike 3.0 // // by Zai Lynch // // // //////////////////////////////////////////////////////
string q0 = "User with questions:"; string q1 = ""; string q2 = ""; string q3 = ""; string q4 = ""; string q5 = ""; string q6 = ""; string q7 = ""; string q8 = ""; erase() { q1 = q2; q2 = q3; q3 = q4; q4 = q5; q5 = q6; q6 = q7; q7 = q8; q8 = ""; } add(string name) { if ((name != q1) && (name != q2) && (name != q3) && (name != q4) && (name != q5) && (name != q6) && (name != q7) && (name != q8)) if (q1=="") q1=name; else if (q2 == "") q2=name; else if (q3 == "") q3=name; else if (q4 == "") q4=name; else if (q5 == "") q5=name; else if (q6 == "") q6=name; else if (q7 == "") q7=name; else if (q8 == "") q8=name; }
state_entry() { llSetText(q0,<1,1,1>,1); } touch_start(integer total_number) { time = llGetUnixTime(); } touch_end(integer num_detected) { if (llGetUnixTime() < time + 3) add(llDetectedName(0)); else erase(); llSetText(q0+"\n"+q1+"\n"+q2+"\n"+q3+"\n"+q4+"\n" +q5+"\n"+q6+"\n"+q7+"\n"+q8, <1,1,1>,1); } } </lsl> |
|