// Davan Camus, 2005 October // Generic template starter script // a little of everything integer COMMAND_CHANNEL = 32; // set to zero to disable integer gListenerNumber = 0; float gTickSize = 0; integer gDebug = 0; string gVersion = "0.0"; // wrapper for set timer event, where we keep track of it. setTimerEvent(float t) { gTickSize = t; llSetTimerEvent(t); } // 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("(dbg) "+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 if(t == TYPE_ROTATION) s += (string)llList2Rot(x,i); else s += "(item " + (string)i + ")"; } return s; } report1(list x) { string s = llDumpList2String(x," "); llShout(COMMAND_CHANNEL,s); d(["reporting: ",s]); } doReport() { string name = llGetObjectName(); report1(["scale",llGetScale()]); report1(["rot",llGetRot()]); report1(["pos",llGetPos()]); } // All commands (link or chat) come through here doCommand(key av,string message) { string name = llToLower(llGetObjectName()); list messageL = llParseString2List(message,[" "],[]); string cmd = llToLower(llList2String(messageL,0)); integer arg1 = llList2Integer(messageL,1); string arg1S = llList2String(messageL,1); string argRest = llGetSubString(message,llStringLength(cmd) + llStringLength(arg1S) + 2,-1); integer arg1OnOff = 0; if(llToLower(arg1S) == "on" || ((integer)arg1S > 0) || arg1S == "" ) arg1OnOff = 1; if(cmd == "report") { doReport(); } if(cmd == name) { d(["cmd: ",cmd,", arg1S: ",arg1S,", argRest: ",argRest]); if(arg1S == "rot") { rotation rot = (rotation)argRest; llSetRot(rot); } else if(arg1S == "scale") { vector scale = (vector)argRest; llSetScale(scale); } else if(arg1S == "pos") { vector pos = (vector)argRest; llSetPos(pos); } } // ... } init() { llListenRemove(gListenerNumber); if(COMMAND_CHANNEL) { gListenerNumber = llListen(COMMAND_CHANNEL,"","",""); d(["listening on ",COMMAND_CHANNEL]); } setTimerEvent(10); } default { on_rez(integer n) { llResetScript(); } state_entry() { init(); d(["state_entry"]); } touch_start(integer total_number) { } listen(integer channel,string name,key id,string message) { d(["listen (",name," on ",channel,"): ",message]); doCommand(id,message); } timer() { } } // end of file