integer S_OFF = 0x0001; // turned off -- not receiving keys integer S_GROUND = 0x0002; // on, ready to jump or fly integer S_JUMP = 0x0004; // in process of jumping integer S_FLOAT = 0x0008; // currently floating integer S_ANCHOR = 0x0010; // floating, but continuously anchored // Davan Camus, 2005 October // Script for flotation device doors antenna integer COMMAND_CHANNEL = 17; integer gListenerNumber = 0; integer gTicks = 0; integer gDebug = 0; integer gLower = 0; // true if this is the lower door vector gLastColor = <-1,-1,-1>; setColor(vector color) { if(color != gLastColor) { gLastColor = color; llSetColor(gLastColor,ALL_SIDES); } } //[PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>] float bump = .05; float gDimple = .3; float gDimpleTarget = .3; setDimple(float e) { gDimpleTarget = e; llSetTimerEvent(.1); } // 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 = list2String(debugList); llOwnerSay(s); } } // Take a list, type-and-cast appropriately, and concat it // all into a string. useful for debug displays. string list2String(list x) { string s = ""; integer len = llGetListLength(x); integer i; for(i = 0; i < len; i++) { integer t = llGetListEntryType(x,i); if(t == TYPE_STRING) s += llList2String(x,i); else if(t == TYPE_INTEGER) s += (string)llList2Integer(x,i); else if(t == TYPE_FLOAT) s += (string)llList2Float(x,i); else if(t == TYPE_FLOAT) s += (string)llList2Float(x,i); else if(t == TYPE_VECTOR) s += (string)llList2Vector(x,i); else s += "(item " + (string)i + ")"; } return s; } init() { string s = llGetObjectName(); if(s == "lower") gLower = 1; else gLower = 0; } integer gOpen = 0; default { on_rez(integer n) { llResetScript(); } state_entry() { init(); } // timer used just as a watchdog to turn off too much pingery, & return to steady. timer() { // list params = llGetPrimitiveParams([PRIM_TYPE]); float d = gDimple; if(d != gDimpleTarget) { if(d < gDimpleTarget) { d += bump; if(d > gDimpleTarget) d = gDimpleTarget; } else { d -= bump; if(d < gDimpleTarget) d = gDimpleTarget; } vector dv; if(gLower) dv = <1-d,1,0>; else dv = <0,d,0>; list params = [PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_DEFAULT, <0,0.5,0>, // /* cut */ .95, // /* hollow */ <0,0,0>, // /* twist */ dv // /* dimple */ ]; llSetPrimitiveParams(params); llSetTimerEvent(.1); gDimple = d; } else llSetTimerEvent(2); } // command structure: "pingSteady r g b" color while not pingShort-ing // command structure: "pingShort r g b duration interval" // set the ball to RGB, and blink at rate "interval" for "duration" link_message(integer senderNum,integer keyNum,string message,key id) { d(["link message received: ",message]); if(keyNum == COMMAND_CHANNEL) { list messageL = llParseString2List(message,[" "],[]); string c = llList2String(messageL,0); if(c == "state") { integer s = llList2Integer(messageL,1); float di = .2; if(s == S_GROUND || s == S_OFF) di = .5; else if(s == S_JUMP) di = .42; setDimple(di); } else if(c == "debug") gDebug = llList2Integer(messageL,1); } } } // end of file