Difference between revisions of "Binary Clock v1.1"
Jump to navigation
Jump to search
m (lsl code tagging) |
Kireji Haiku (talk | contribs) m (some minor memory usage improvements) |
||
Line 29: | Line 29: | ||
{ | { | ||
integer shiftraw = (integer)llGetWallclock(); | integer shiftraw = (integer)llGetWallclock(); | ||
integer hours = shiftraw / 3600; | integer hours = shiftraw / 3600; | ||
integer minutes = (shiftraw % 3600) / 60; | integer minutes = (shiftraw % 3600) / 60; | ||
integer seconds = shiftraw % 60; | integer seconds = shiftraw % 60; | ||
bTime = [hours / 10, hours % 10, | bTime = [hours / 10, hours % 10, | ||
minutes / 10, minutes % 10, | minutes / 10, minutes % 10, | ||
seconds / 10, seconds % 10]; | seconds / 10, seconds % 10]; | ||
} | } | ||
Line 48: | Line 48: | ||
string rowA = dec2bin(current_rowA); | string rowA = dec2bin(current_rowA); | ||
integer Acol0 = (integer)llGetSubString(rowA, 3, 3); | integer Acol0 = (integer)llGetSubString(rowA, 3, 3); | ||
integer Acol1 = (integer)llGetSubString(rowA, 2, 2); | integer Acol1 = (integer)llGetSubString(rowA, 2, 2); | ||
MessageLinked(2, Acol0); | |||
MessageLinked(3, Acol1); | |||
} | } | ||
else if (!current_rowA) | |||
{ | |||
MessageLinked(2, 0); | |||
MessageLinked(3, 0); | |||
} | |||
integer current_rowB = llList2Integer(bTime, 1); | integer current_rowB = llList2Integer(bTime, 1); | ||
integer old_rowB = llList2Integer(oTime, 1); | integer old_rowB = llList2Integer(oTime, 1); | ||
Line 64: | Line 67: | ||
integer Bcol1 = (integer)llGetSubString(rowB, 2, 2); | integer Bcol1 = (integer)llGetSubString(rowB, 2, 2); | ||
integer Bcol2 = (integer)llGetSubString(rowB, 1, 1); | integer Bcol2 = (integer)llGetSubString(rowB, 1, 1); | ||
integer Bcol3 = (integer)llGetSubString(rowB, 0, 0); | integer Bcol3 = (integer)llGetSubString(rowB, 0, 0); | ||
MessageLinked(4, Bcol0); | |||
MessageLinked(5, Bcol1); | |||
MessageLinked(6, Bcol2); | |||
MessageLinked(7, Bcol3); | |||
} | } | ||
else if (!current_rowB) | |||
{ | |||
MessageLinked(4, 0); | |||
MessageLinked(5, 0); | |||
MessageLinked(6, 0); | |||
MessageLinked(7, 0); | |||
} | |||
integer current_rowC = llList2Integer(bTime, 2); | integer current_rowC = llList2Integer(bTime, 2); | ||
integer old_rowC = llList2Integer(oTime, 2); | integer old_rowC = llList2Integer(oTime, 2); | ||
if (current_rowC != old_rowC) | if (current_rowC != old_rowC) | ||
{ | { | ||
string rowC = dec2bin(current_rowC); | string rowC = dec2bin(current_rowC); | ||
integer Ccol0 = (integer)llGetSubString(rowC, 3, 3); | integer Ccol0 = (integer)llGetSubString(rowC, 3, 3); | ||
integer Ccol1 = (integer)llGetSubString(rowC, 2, 2); | integer Ccol1 = (integer)llGetSubString(rowC, 2, 2); | ||
integer Ccol2 = (integer)llGetSubString(rowC, 1, 1); | integer Ccol2 = (integer)llGetSubString(rowC, 1, 1); | ||
MessageLinked(8, Ccol0); | |||
MessageLinked(9, Ccol1); | |||
MessageLinked(10, Ccol2); | |||
} else if (!current_rowC) { | } | ||
else if (!current_rowC) | |||
{ | |||
MessageLinked(8, 0); | |||
MessageLinked(9, 0); | |||
MessageLinked(10, 0); | |||
} | } | ||
integer current_rowD = llList2Integer(bTime, 3); | integer current_rowD = llList2Integer(bTime, 3); | ||
integer old_rowD = llList2Integer(oTime, 3); | integer old_rowD = llList2Integer(oTime, 3); | ||
Line 102: | Line 110: | ||
integer Dcol1 = (integer)llGetSubString(rowD, 2, 2); | integer Dcol1 = (integer)llGetSubString(rowD, 2, 2); | ||
integer Dcol2 = (integer)llGetSubString(rowD, 1, 1); | integer Dcol2 = (integer)llGetSubString(rowD, 1, 1); | ||
integer Dcol3 = (integer)llGetSubString(rowD, 0, 0); | integer Dcol3 = (integer)llGetSubString(rowD, 0, 0); | ||
MessageLinked(11, Dcol0); | |||
MessageLinked(12, Dcol1); | |||
MessageLinked(13, Dcol2); | |||
MessageLinked(14, Dcol3); | |||
} | } | ||
else if (!current_rowD) | |||
{ | |||
MessageLinked(11, 0); | |||
MessageLinked(12, 0); | |||
MessageLinked(13, 0); | |||
MessageLinked(14, 0); | |||
} | |||
integer current_rowE = llList2Integer(bTime, 4); | integer current_rowE = llList2Integer(bTime, 4); | ||
integer old_rowE = llList2Integer(oTime, 4); | integer old_rowE = llList2Integer(oTime, 4); | ||
Line 122: | Line 133: | ||
integer Ecol1 = (integer)llGetSubString(rowE, 2, 2); | integer Ecol1 = (integer)llGetSubString(rowE, 2, 2); | ||
integer Ecol2 = (integer)llGetSubString(rowE, 1, 1); | integer Ecol2 = (integer)llGetSubString(rowE, 1, 1); | ||
MessageLinked(15, Ecol0); | |||
MessageLinked(16, Ecol1); | |||
} else if (!current_rowE) { | MessageLinked(17, Ecol2); | ||
} | |||
else if (!current_rowE) | |||
{ | |||
MessageLinked(15, 0); | |||
MessageLinked(16, 0); | |||
MessageLinked(17, 0); | |||
} | } | ||
integer current_rowF = llList2Integer(bTime, 5); | integer current_rowF = llList2Integer(bTime, 5); | ||
integer old_rowF = llList2Integer(oTime, 5); | integer old_rowF = llList2Integer(oTime, 5); | ||
Line 139: | Line 153: | ||
integer Fcol1 = (integer)llGetSubString(rowF, 2, 2); | integer Fcol1 = (integer)llGetSubString(rowF, 2, 2); | ||
integer Fcol2 = (integer)llGetSubString(rowF, 1, 1); | integer Fcol2 = (integer)llGetSubString(rowF, 1, 1); | ||
integer Fcol3 = (integer)llGetSubString(rowF, 0, 0); | integer Fcol3 = (integer)llGetSubString(rowF, 0, 0); | ||
MessageLinked(18, Fcol0); | |||
MessageLinked(19, Fcol1); | |||
MessageLinked(20, Fcol2); | |||
} else if (!current_rowF) { | MessageLinked(21, Fcol3); | ||
} | |||
else if (!current_rowF) | |||
{ | |||
MessageLinked(18, 0); | |||
MessageLinked(19, 0); | |||
MessageLinked(20, 0); | |||
MessageLinked(21, 0); | |||
} | } | ||
} | |||
MessageLinked(integer inputLinkNumber, integer inputNumber) | |||
{ | |||
llMessageLinked(inputLinkNumber, inputNumber, "", ""); | |||
} | } | ||
Line 157: | Line 179: | ||
touch_start(integer total_number) | touch_start(integer total_number) | ||
{ | { | ||
key owner = llGetOwner(); | |||
key id = llDetectedKey(0); | |||
if (id != owner) | |||
return; | |||
if (token) | |||
{ | |||
token = 0; | |||
llOwnerSay("Off!"); | |||
llSetTimerEvent((float)FALSE); | |||
} | |||
else | |||
{ | { | ||
oTime = []; | oTime = []; | ||
bTime = []; | bTime = []; | ||
token = 1; | token = 1; | ||
llOwnerSay("On!"); | llOwnerSay("On!"); | ||
llSetTimerEvent(1.0); | |||
llSetTimerEvent(0 | |||
} | } | ||
} | } | ||
timer() | timer() | ||
{ | { |
Revision as of 12:16, 7 October 2012
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Binary Clock V1.1
<lsl> // Binary Clock Script // By Fox Diller // OMG INSANITY!
list bTime; list oTime;
integer token;
string dec2bin(integer dec) {
if (dec == 0) return "0000"; if (dec == 1) return "0001"; if (dec == 2) return "0010"; if (dec == 3) return "0011"; if (dec == 4) return "0100"; if (dec == 5) return "0101"; if (dec == 6) return "0110"; if (dec == 7) return "0111"; if (dec == 8) return "1000"; if (dec == 9) return "1001"; return "0000";
}
BuildClock() {
integer shiftraw = (integer)llGetWallclock();
integer hours = shiftraw / 3600; integer minutes = (shiftraw % 3600) / 60; integer seconds = shiftraw % 60;
bTime = [hours / 10, hours % 10, minutes / 10, minutes % 10, seconds / 10, seconds % 10];
}
displayBDC() {
integer current_rowA = llList2Integer(bTime, 0); integer old_rowA = llList2Integer(oTime, 0); if (current_rowA != old_rowA) { string rowA = dec2bin(current_rowA); integer Acol0 = (integer)llGetSubString(rowA, 3, 3); integer Acol1 = (integer)llGetSubString(rowA, 2, 2);
MessageLinked(2, Acol0); MessageLinked(3, Acol1); } else if (!current_rowA) { MessageLinked(2, 0); MessageLinked(3, 0); }
integer current_rowB = llList2Integer(bTime, 1); integer old_rowB = llList2Integer(oTime, 1); if (current_rowB != old_rowB) { string rowB = dec2bin(current_rowB); integer Bcol0 = (integer)llGetSubString(rowB, 3, 3); integer Bcol1 = (integer)llGetSubString(rowB, 2, 2); integer Bcol2 = (integer)llGetSubString(rowB, 1, 1); integer Bcol3 = (integer)llGetSubString(rowB, 0, 0);
MessageLinked(4, Bcol0); MessageLinked(5, Bcol1); MessageLinked(6, Bcol2); MessageLinked(7, Bcol3); } else if (!current_rowB) { MessageLinked(4, 0); MessageLinked(5, 0); MessageLinked(6, 0); MessageLinked(7, 0); }
integer current_rowC = llList2Integer(bTime, 2); integer old_rowC = llList2Integer(oTime, 2); if (current_rowC != old_rowC) { string rowC = dec2bin(current_rowC); integer Ccol0 = (integer)llGetSubString(rowC, 3, 3); integer Ccol1 = (integer)llGetSubString(rowC, 2, 2); integer Ccol2 = (integer)llGetSubString(rowC, 1, 1); MessageLinked(8, Ccol0); MessageLinked(9, Ccol1); MessageLinked(10, Ccol2); } else if (!current_rowC) { MessageLinked(8, 0); MessageLinked(9, 0); MessageLinked(10, 0); }
integer current_rowD = llList2Integer(bTime, 3); integer old_rowD = llList2Integer(oTime, 3); if (current_rowD != old_rowD) { string rowD = dec2bin(current_rowD); integer Dcol0 = (integer)llGetSubString(rowD, 3, 3); integer Dcol1 = (integer)llGetSubString(rowD, 2, 2); integer Dcol2 = (integer)llGetSubString(rowD, 1, 1); integer Dcol3 = (integer)llGetSubString(rowD, 0, 0);
MessageLinked(11, Dcol0); MessageLinked(12, Dcol1); MessageLinked(13, Dcol2); MessageLinked(14, Dcol3); } else if (!current_rowD) { MessageLinked(11, 0); MessageLinked(12, 0); MessageLinked(13, 0); MessageLinked(14, 0); }
integer current_rowE = llList2Integer(bTime, 4); integer old_rowE = llList2Integer(oTime, 4); if (current_rowE != old_rowE) { string rowE = dec2bin(current_rowE); integer Ecol0 = (integer)llGetSubString(rowE, 3, 3); integer Ecol1 = (integer)llGetSubString(rowE, 2, 2); integer Ecol2 = (integer)llGetSubString(rowE, 1, 1);
MessageLinked(15, Ecol0); MessageLinked(16, Ecol1); MessageLinked(17, Ecol2); } else if (!current_rowE) { MessageLinked(15, 0); MessageLinked(16, 0); MessageLinked(17, 0); }
integer current_rowF = llList2Integer(bTime, 5); integer old_rowF = llList2Integer(oTime, 5); if (current_rowF != old_rowF) { string rowF = dec2bin(current_rowF); integer Fcol0 = (integer)llGetSubString(rowF, 3, 3); integer Fcol1 = (integer)llGetSubString(rowF, 2, 2); integer Fcol2 = (integer)llGetSubString(rowF, 1, 1); integer Fcol3 = (integer)llGetSubString(rowF, 0, 0);
MessageLinked(18, Fcol0); MessageLinked(19, Fcol1); MessageLinked(20, Fcol2); MessageLinked(21, Fcol3); } else if (!current_rowF) { MessageLinked(18, 0); MessageLinked(19, 0); MessageLinked(20, 0); MessageLinked(21, 0); }
}
MessageLinked(integer inputLinkNumber, integer inputNumber) {
llMessageLinked(inputLinkNumber, inputNumber, "", "");
}
default {
touch_start(integer total_number) { key owner = llGetOwner(); key id = llDetectedKey(0);
if (id != owner) return;
if (token) { token = 0; llOwnerSay("Off!"); llSetTimerEvent((float)FALSE); } else { oTime = []; bTime = []; token = 1; llOwnerSay("On!"); llSetTimerEvent(1.0); } }
timer() { bTime = oTime; BuildClock(); displayBDC(); }
} </lsl>