Difference between revisions of "User:Zai Lynch/Sandbox/LSL Goodies"

From Second Life Wiki
Jump to navigation Jump to search
m (1st draft)
 
m (formatting)
Line 7: Line 7:
== Intro ==
== Intro ==
<div style="padding: 0.5em">
<div style="padding: 0.5em">
So just for the record: I'm a complete LSL n00b. So don't expect much from this page. Since I love the Open Source concept, I'd like to share some of my scripts with other SL Residents =)<br>
So 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 =)<br>
Since these are contributions to the SL Wiki, all scripts are released under [http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-Share Alike 3.0 License].
Since these are contributions to the SL Wiki, all scripts are released under [http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-Share Alike 3.0 License].
</div></div>
</div></div>
Line 13: Line 13:


<div id="box">
<div id="box">
== Simple Timer ==
== Simple Countdown ==
<div style="padding: 0.5em">
<div style="padding: 0.5em">
This script displays a hovering countdown.
This script displays a hovering countdown above the item it's placed in.




Line 27: Line 27:
//                                                  //
//                                                  //
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
 
 
integer DAYS    = 28;        // Days until the countdown finishs
integer DAYS    = 28;        // Days until the countdown finishs
integer HOURS    = 6;        // Hours until the countdown finishs
integer HOURS    = 6;        // Hours until the countdown finishs
Line 36: Line 36:
string  FINISHED = "uh oh..."; // Text displayed when event happened
string  FINISHED = "uh oh..."; // Text displayed when event happened
vector  COLOR = <1,1,1>;    // Color of the displayed text   
vector  COLOR = <1,1,1>;    // Color of the displayed text   
 
 
countdown()
countdown()
{
{
     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);
     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
default
{
{
Line 53: Line 56:
         countdown();
         countdown();
     }
     }
 
 
     timer()
     timer()
     {
     {

Revision as of 11:51, 28 May 2008


Intro

So 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 =)
Since these are contributions to the SL Wiki, all scripts are released under Creative Commons Attribution-Share Alike 3.0 License.


Simple Countdown

This script displays a hovering countdown above the item it's placed in.


<lsl> ////////////////////////////////////////////////////// // // // Simple Countdown Script // // Released under // // Creative Commons Attribution-Share Alike 3.0 // // by Zai Lynch // // // //////////////////////////////////////////////////////


integer DAYS = 28; // Days until the countdown finishs integer HOURS = 6; // Hours until the countdown finishs integer MINUTES = 42; // Minutes until the countdown finishs integer SECONDS = 12; // Seconds until the countdown finishs string TEXT = "The end of the world will come in"; // Additional text defining the event string FINISHED = "uh oh..."; // Text displayed when event happened vector COLOR = <1,1,1>; // Color of the displayed text


countdown() {

   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>


Script 2

script


Script 3

script


Zai landing.png