// Davan Camus, 2005 November // file: dance_floor.lsl // // Modification of bulb script -- lets link // messages control surface animation // link on COMMAND_CHANNEL: // "state 0|1|2" 0 == dark, 1 == light, 2 == fullbright only // // txscale x <-- sets texturescale to x-repeats // txrotv v <-- sets texture rotation speed // txtrnv v <-- sets texture gliding speed // // works well with lamp_controller.lsl.c // // // 2005.12.03, thoughts on additional commands: // // Do a blink on/off, not necessarily perfectly steady: // blink min-time-on/max-time-on min-time-off/max-time-off // // Cycle through some colors, not necessarily perfectly steady // Allow each blink to be interp tween colors? // (any rgb=0 means "off") // cycle / 1|0 min-hold-time/max-hold-time // // Animate a (for example pulsating) texture or no // pulse float-rpts-per-second // // Filament brightness (if supported, by sizing the interior Light element) // brightness zero-to-a-hundred // // Spotlight or glow strength (if supported with a beam-casting prim, or particles...) // glow zero-to-a-hundred // // And other non-lighting commands: // something for positioning or pointing... // choosing a stop-motion frame for animated sculptures... // //string version = "0.1 2005.11.13"; string version = "0.7 2006.11.20"; integer COMMAND_CHANNEL = 925; // always-on channel integer gDebug = 0; float gRadius = 10.0; float gIntensity = 1.0; float gFalloff = 0.5; // d([this, that, the other]); prints debug stuff // (I find it easier to type the [list,notation] than all // that tedious casting-to-string and adding stuff d(list debugList) { if(!gDebug) return; else { string s = (string)(debugList); llOwnerSay("(dbg) "+s); } } sayBSetting(string setting,integer b) { string v; if(b) v = "On"; else v = "Off"; llSay(0,setting + ": " + v); } sayVSetting(string setting,vector v) { llSay(0,(string)([setting,": ",v])); } showInfo(integer isGuest) { llSleep(llFrand(3)); // to stagger responses sayBSetting("Bulb",gAppearanceKind); sayVSetting("Bulb Color",gAppearanceColor); } // do the actual materials/colors change, // applies to owner/guest transition, dusk, all of em. integer gAppearanceKind = 0; vector gAppearanceColor = <0,0,0>; setLampAppearance(integer lightKind,vector color) { integer doFlicker = gAppearanceKind != lightKind; d(["setLampAppearance(",lightKind,",",color,")"]); if(doFlicker) { integer i; for(i = 0; i < 10; i++) { setParams((color / 2.0) + (color * llFrand(0.5)),lightKind); llSleep(.1); } } vector tColor = color; if(lightKind == 0) tColor = tColor / 5.0; // color change? do ramping... if((gAppearanceColor != color) && (gAppearanceKind == lightKind)) { integer steps = 10; integer i; for(i = 0; i < steps; i++) { vector aColor = gAppearanceColor + i * (color - gAppearanceColor) / steps; setParams(aColor,lightKind); llSleep(.1); } } setParams(tColor,lightKind); gAppearanceColor = color; gAppearanceKind = lightKind; } setParams(vector color,integer lightKind) { llSetColor(color,ALL_SIDES); integer fb = lightKind > 0; // fullbright for light or fullbright integer li = lightKind == 1; // is a "light" llSetPrimitiveParams([PRIM_POINT_LIGHT,li,color,gIntensity,gRadius,gFalloff,PRIM_FULLBRIGHT,ALL_SIDES,fb]); } init() { gDebug = 0; d(["linking from ",COMMAND_CHANNEL]); d([llGetFreeMemory()," bytes free"]); llSetTouchText(" "); setLampAppearance(0,<0,0,0>); } default { on_rez(integer n) { llResetScript(); } state_entry() { init(); d(["state_entry"]); } link_message(integer senderNum,integer keyNum,string message,key id) { d(["link message received: [",keyNum,"] ",message]); if(keyNum == COMMAND_CHANNEL) { list messageL = llParseString2List(message,["++"],[]); string c = llList2String(messageL,0); if(c == "state") { d([llGetListLength(messageL),":",llList2String(messageL,1),",",llList2String(messageL,2)]); vector color = (vector)llList2String(messageL,1); integer lightKind = llList2Integer(messageL,2); d([color," : ",lightKind]); setLampAppearance(lightKind,color); } else if(c == "txcale") { } else if(c == "debug") gDebug = llList2Integer(messageL,1); } } } // end of file