User:Fox Diller/LCDClock

From Second Life Wiki
< User:Fox Diller
Revision as of 21:00, 30 March 2008 by Uzume Grigorovich (talk | contribs) (lsl code tagging)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<lsl> integer t;

integer hours; integer minutes; integer seconds;

integer tog = 0; integer counter = 0;


getPSTtime() {

   t = (integer)llGetWallclock();
   hours = t / 3600; 
   minutes = (t % 3600) / 60; 
   seconds = t % 60;

}


logic1_2(integer displayNum) {

   if (displayNum) {
       llSetLinkAlpha(26, 1.0, ALL_SIDES);llSetLinkAlpha(25, 1.0, ALL_SIDES);
   }
   
   if (!displayNum) {
       llSetLinkAlpha(26, 0.1, ALL_SIDES);llSetLinkAlpha(25, 0.1, ALL_SIDES);
   }
   

}

logic2_8(integer displayNum) {

   if(displayNum == 0) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 0.1, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 1.0, ALL_SIDES);
   }
   if(displayNum == 1) {
       llSetLinkAlpha(18, 0.1, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 0.1, ALL_SIDES);llSetLinkAlpha(22, 0.1, ALL_SIDES);llSetLinkAlpha(23, 0.1, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   if(displayNum == 2) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 0.1, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 0.1, ALL_SIDES);llSetLinkAlpha(24, 1.0, ALL_SIDES);
   }
   if(displayNum == 3) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 0.1, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   if(displayNum == 4) {
       llSetLinkAlpha(18, 0.1, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 0.1, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   if(displayNum == 5) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 0.1, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   if(displayNum == 6) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 0.1, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 1.0, ALL_SIDES);
   }
   if(displayNum == 7) {
       llSetLinkAlpha(18, 0.1, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 0.1, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 0.1, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   if(displayNum == 8) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 1.0, ALL_SIDES);
   }
   if(displayNum == 9) {
       llSetLinkAlpha(18, 1.0, ALL_SIDES);llSetLinkAlpha(19, 1.0, ALL_SIDES);llSetLinkAlpha(20, 1.0, ALL_SIDES);llSetLinkAlpha(21, 1.0, ALL_SIDES);llSetLinkAlpha(22, 1.0, ALL_SIDES);llSetLinkAlpha(23, 1.0, ALL_SIDES);llSetLinkAlpha(24, 0.1, ALL_SIDES);
   }
   

}

logic3_8(integer displayNum) {

   if(displayNum == 0) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 1.0, ALL_SIDES);llSetLinkAlpha(13, 0.1, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }
   if(displayNum == 1) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 0.1, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 0.1, ALL_SIDES);llSetLinkAlpha(14, 0.1, ALL_SIDES);llSetLinkAlpha(15, 0.1, ALL_SIDES);
   }
   if(displayNum == 2) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 0.1, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 1.0, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 0.1, ALL_SIDES);
   }
   if(displayNum == 3) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 0.1, ALL_SIDES);
   }
   if(displayNum == 4) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 0.1, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 0.1, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }
   if(displayNum == 5) {
       llSetLinkAlpha(9, 0.1, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }
   if(displayNum == 6) {
       llSetLinkAlpha(9, 0.1, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 1.0, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }
   if(displayNum == 7) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 0.1, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 0.1, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 0.1, ALL_SIDES);
   }
   if(displayNum == 8) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 1.0, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }
   if(displayNum == 9) {
       llSetLinkAlpha(9, 1.0, ALL_SIDES);llSetLinkAlpha(10, 1.0, ALL_SIDES);llSetLinkAlpha(11, 1.0, ALL_SIDES);llSetLinkAlpha(12, 0.1, ALL_SIDES);llSetLinkAlpha(13, 1.0, ALL_SIDES);llSetLinkAlpha(14, 1.0, ALL_SIDES);llSetLinkAlpha(15, 1.0, ALL_SIDES);
   }

}

logic4_8(integer displayNum) {

   if(displayNum == 0) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 1.0, ALL_SIDES);llSetLinkAlpha(5, 0.1, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }
   if(displayNum == 1) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 0.1, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 0.1, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 0.1, ALL_SIDES);llSetLinkAlpha(8, 0.1, ALL_SIDES);
   }
   if(displayNum == 2) {
       llSetLinkAlpha(2, 0.1, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 1.0, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 0.1, ALL_SIDES);
   }
   if(displayNum == 3) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 0.1, ALL_SIDES);
   }
   if(displayNum == 4) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 0.1, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 0.1, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }
   if(displayNum == 5) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 0.1, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }
   if(displayNum == 6) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 1.0, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 0.1, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }
   if(displayNum == 7) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 0.1, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 0.1, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 0.1, ALL_SIDES);
   }
   if(displayNum == 8) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 1.0, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }
   if(displayNum == 9) {
       llSetLinkAlpha(2, 1.0, ALL_SIDES);llSetLinkAlpha(3, 1.0, ALL_SIDES);llSetLinkAlpha(4, 0.1, ALL_SIDES);llSetLinkAlpha(5, 1.0, ALL_SIDES);llSetLinkAlpha(6, 1.0, ALL_SIDES);llSetLinkAlpha(7, 1.0, ALL_SIDES);llSetLinkAlpha(8, 1.0, ALL_SIDES);
   }

}


setHours(integer hour) {

   if (hour == -1) {
       logic1_2(0);
       logic2_8(0);   
   }
   if (hour <= 9 && hour != 0) {
       logic1_2(0);
       logic2_8(hour);
   }
   if (hour <= 12 && hour >= 10) {
       logic1_2(1);
       if(hour == 10) logic2_8(0);
       if(hour == 11) logic2_8(1);
       if(hour == 12) logic2_8(2);   
   }
   if (hour <= 21 && hour >= 11) {
       logic1_2(0);
       logic2_8(hour - 12);
   }
   if (hour <= 23 && hour >= 22) {
       logic1_2(1);
       if(hour == 22) logic2_8(0);
       if(hour == 23) logic2_8(1);
   }
   if (hour == 0) {
       logic1_2(1);
       logic2_8(2);
   }

}

setMins(integer minute) {

   if(minute <= 9) {
       logic3_8(0);
       logic4_8(minute);    
   }
   if(minute <= 19 && minute >= 10) {
       logic3_8(1);
       logic4_8(minute - 10);   
   }
   if(minute <= 29 && minute >= 20) {
       logic3_8(2);
       logic4_8(minute - 20);
   }
   if(minute <= 39 && minute >= 30) {
       logic3_8(3);
       logic4_8(minute - 30);
   }
   if(minute <= 49 && minute >= 40) {
       logic3_8(4);
       logic4_8(minute - 40);
   }
   if(minute <= 59 && minute >= 50) {
       logic3_8(5);
       logic4_8(minute - 50);
   }

}


default {

   state_entry()
   {
       llSetTimerEvent(10);
       tog = 0;
       getPSTtime();
       setHours(hours);
       setMins(minutes);
   }
   
   timer()
   {
       llSetLinkAlpha(16, 1.0, ALL_SIDES);
       llSetLinkAlpha(17, 1.0, ALL_SIDES);
           getPSTtime();
           setHours(hours);
           setMins(minutes);
       llSetLinkAlpha(16, 0.1, ALL_SIDES);
       llSetLinkAlpha(17, 0.1, ALL_SIDES);      
   }
   touch_start(integer total_number)
   {
       state tellSecs;
   }

}

state tellSecs {

   state_entry()
   {
       counter = 0;
       llSetTimerEvent(1);
       getPSTtime();
       setHours(-1);
       setMins(seconds);
   }
   
   timer()
   {
       llSetLinkAlpha(16, 1.0, ALL_SIDES);
       llSetLinkAlpha(17, 1.0, ALL_SIDES);
       getPSTtime();
       setHours(-1);
       setMins(seconds);
       counter++;
       llSetLinkAlpha(16, 0.1, ALL_SIDES);
       llSetLinkAlpha(17, 0.1, ALL_SIDES);
       if (counter == 10) state default;
   }
   
   touch_start(integer a)
   {
       state default;
   }

} </lsl>