// 2006.12.10 dancepad receiver list COMMAND_CHANNELS = [303]; // listen on any number of channels, for shared control groupings integer SHOW_CHANNEL = 0; // if 1, show channel hovering above object. string SETUP = "setup"; // name of notecard to config with integer gDebug = 0; integer gCurrentSetupLine; d(list debugList) { if(gDebug) { string s = (string)debugList; llOwnerSay("(dbg) "+s); } } init() { // dance setup, with debug messages intact expecteddesc = llGetObjectDesc(); llSetText("Loading", <0,.5,1>,1); string desc = llGetObjectDesc(); llSay(7, "desc: [" + desc + "]"); list bits = llParseString2List(llGetObjectDesc(), ["=", "(", ")", " "], []); float height = llList2Float(bits, 1); title = llDumpList2String( llList2List(bits, 2, -1), " "); llSay(7, "Height: [" + (string)height + "]"); llSay(8, title); offset = <0,0,-1 * height >; llSitTarget(offset, llEuler2Rot(ROTATION * DEG_TO_RAD)); loadanimation(); llSetTimerEvent(10); // if there's a config card, commence reading it if(llGetInventoryType(SETUP) == INVENTORY_NOTECARD) { llSetText("[reading " + SETUP + "]",<1,0,0>,1); gCurrentSetupLine = 0; llGetNotecardLine(SETUP,gCurrentSetupLine++); } else doneWithSetup(); activate(0); // turn off initially } gotSetupLine(string message) { if(message == EOF) { doneWithSetup(); return; } // start fetching the next line llGetNotecardLine(SETUP,gCurrentSetupLine++); // and do something with this one list messageL = llParseString2List(message,[" "],[]); string cmd = llList2String(messageL,0); if(cmd == "channels") COMMAND_CHANNELS = llList2List(messageL,1,-1); } doneWithSetup() { if(SHOW_CHANNEL) llSetText((string)["channels: [",llDumpList2String(COMMAND_CHANNELS,", "),"]\nfree: ",llGetFreeMemory()],<1,1,1>,1); integer k = llGetListLength(COMMAND_CHANNELS); while(k-- >= 0) llListen(llList2Integer(COMMAND_CHANNELS,k),"","",""); d(["free: ",llGetFreeMemory()]); } doCommand(string message) { d([message]); if(message == "") { // doDialog(av); return; } list messageL = llParseString2List(message,[" "],[]); string cmd = llToLower(llList2String(messageL,0)); integer arg1 = llList2Integer(messageL,1); float arg1F = llList2Float(messageL,1); string arg1S = llList2String(messageL,1); integer arg1OnOff = 0; if(llToLower(arg1S) == "on" || ((integer)arg1S > 0) || arg1S == "" ) arg1OnOff = 1; if(cmd == "dance") { // if this is our dance, activate and be visible // else, deactivate and be invisible string rest = llGetSubString(message,6,-1); integer isUs = (rest == gAnimation); isUs = isUs | (llToLower(rest) == llToLower(llGetObjectName())); if(rest == "all") isUs = 1; // "none" would turn them all off, if no dance is named "none" ha ha. d(["dance ",rest,": ",isUs]); activate(isUs); } else if(cmd == "debug") { gDebug = arg1OnOff; d(["debug is ",gDebug]); } } integer gActive = 9; activate(integer x) { gActive = x; if(gActive) { llSetAlpha(1.0, ALL_SIDES); llSetTouchText("Dance!"); llSetSitText("Dance!"); llSetText(title, <0,1,.5>,1); } else { llSetText("", <0,0,0>,0); llSetAlpha(0.0, ALL_SIDES); llSetTouchText("-"); llSetSitText("-"); avatar = llAvatarOnSitTarget(); if(avatar!= NULL_KEY) llUnSit(avatar); } } // Original dancepad dance script vector ROTATION = <0,0,0>; //marked in degrees string title = "Right Click to Dance"; string gAnimation; vector offset; integer hidden = FALSE; key avatar; key trigger; string expecteddesc; stopdancing() { activate(gActive); } startdancing() { llSay(6, "starting to dance!"); hidden = TRUE; llSetText("", <1,1,1>,1); llSetAlpha(0.4, ALL_SIDES); llStopAnimation("sit"); llStartAnimation(gAnimation); } loadanimation() { if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) { llWhisper(0,"Please place an animation into the pad."); llSetText("Please Add Animation", <1,.3,.5>, 1); return; } else { gAnimation = llGetInventoryName(INVENTORY_ANIMATION,0); } stopdancing(); activate(gActive); } default { on_rez(integer n) { init(); } dataserver(key queryKey,string message) { gotSetupLine(message); } changed(integer k) { if(k & CHANGED_LINK) { avatar = llAvatarOnSitTarget(); if(avatar!= NULL_KEY) { if(gActive) { llSay(5, "Requesting Permissions"); llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION); } else llUnSit(avatar); } else { if( (llKey2Name(llGetPermissionsKey()) != "") && (trigger == llGetPermissionsKey()) ) { stopdancing(); llStopAnimation(gAnimation); trigger = NULL_KEY; } } } else if(k == CHANGED_INVENTORY) llResetScript(); } state_entry() { init(); } touch_start(integer total_number) { } listen(integer channel,string name,key id,string message) { doCommand(message); } timer() { // dance height thingie if(llGetObjectDesc() != expecteddesc) { d(["Height change detected, resetting script"]); llResetScript(); } } link_message(integer senderNum,integer keyNum,string message,key id) { } run_time_permissions(integer perm) { llSay(5, "permission granted"); avatar = llAvatarOnSitTarget(); if( (perm & PERMISSION_TRIGGER_ANIMATION) && (llKey2Name(avatar) != "") && (avatar == llGetPermissionsKey())) { trigger = avatar; startdancing(); } } } //default //{ // state_entry() // { // expecteddesc = llGetObjectDesc(); // // llSetText("Loading", <0,.5,1>,1); // string desc = llGetObjectDesc(); // llSay(7, "desc: [" + desc + "]"); // list bits = llParseString2List(llGetObjectDesc(), ["=", "(", ")", " "], []); // float height = llList2Float(bits, 1); // title = llDumpList2String( llList2List(bits, 2, -1), " "); // // llSay(7, "Height: [" + (string)height + "]"); // llSay(8, title); // offset = <0,0,-1 * height >; // llSitTarget(offset, llEuler2Rot(ROTATION * DEG_TO_RAD)); // loadanimation(); // llSetTimerEvent(3); // } // // timer() // { // if(llGetObjectDesc() != expecteddesc) // { // llSay(0, "Height change detected, resetting script"); // llResetScript(); // } // } // // changed(integer change) // { // if(change & CHANGED_LINK) // { // avatar = llAvatarOnSitTarget(); // if(avatar!= NULL_KEY) // { // llSay(5, "Requesting Permissions"); // llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION); // } // else // { // if( (llKey2Name(llGetPermissionsKey()) != "") && (trigger == llGetPermissionsKey()) ) // { // stopdancing(); // llStopAnimation(animation); // trigger = NULL_KEY; // } // } // } // if(change & CHANGED_INVENTORY) // { // llSetText("Reloading...",<.7,.7,.2>,1); // loadanimation(); // } // } // // run_time_permissions(integer perm) // { // llSay(5, "permission granted"); // avatar = llAvatarOnSitTarget(); // if( (perm & PERMISSION_TRIGGER_ANIMATION) && (llKey2Name(avatar) != "") && (avatar == llGetPermissionsKey())) // { // trigger = avatar; // startdancing(); // } // } //} // end of file