Dataserver corrected sensor display
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Dataserver corrected sensor display
--BETLOG Hax UTC+10: 20090703 1045 [SLT: 20090702 1745]
<lsl> //========================================================================= // BETLOG Hax // For Bio Flow - complete rewrite based on his script :'take 2.4 moved to dataserver' // UTC10: 20090412 1737 [SLT: 20090412 0037] //========================================================================= //========================================================================= // LICENCE: // Creative Commons Attribution-Share Alike 3.0 license // http://creativecommons.org/licenses/by-sa/3.0/ // You can modify this script, but you must prominently state that you // used this script, credit it's original author(s), and supply this // unaltered script with your modification. // // If you significantly rework my script: // I suggest that you include a full permissions notecard in your object called // 'CREDITS', into which you drag the original/unaltered version of this script. // OR // If you use my original script unaltered: (or just edit a few of my global variables) // Simply use my original script as-is: with the same (full) permissions, // and in the original script that lists BETLOG Hax as it's creator. // // Either of these two options gives 'attribution' and complies with this licence. // If this script is supplied as part of a working object, then the whole object // //========================================================================= // CONFIGURATION float gDisplayFreq = 5.0; float gScanFreq = 1.0; integer gStride = 3; //---------------------------------- // CORE CODE key gQueryId; list gDataList = []; list gQueryList = []; integer gPrims; integer gLink; //---------------------------------- default { on_rez(integer start)
{ llResetScript(); } changed(integer change) { if (change & CHANGED_LINK) llResetScript(); } state_entry() { llSetText("", <1.0, 1.0, 1.0>, 1.0); gPrims = llGetNumberOfPrims(); llSensorRepeat("","",PASSIVE|SCRIPTED, 20.0, PI, gScanFreq); llSetTimerEvent(gDisplayFreq); integer c = gPrims; while(c>1) llMessageLinked(c--,7 ,"",""); //reset all the text } sensor(integer num) { key uuid; key owner; integer range; while(num>0) { --num; uuid = llDetectedKey(num); owner = llDetectedOwner(num); if(uuid != (key)"" && uuid != llGetOwner() && owner != llGetOwner() && ~llDetectedType(num) & AGENT && !llSameGroup(uuid) && -1==llListFindList(gDataList, [uuid])) { if (llKey2Name(owner) == "") { gQueryId = llRequestAgentData(owner, DATA_NAME); gDataList += [range, "UNKNOWN", uuid]; gQueryList += [gQueryId, uuid];
//llOwnerSay("UNRESOLVED name- querying dataserver");
} else { gDataList += [llRound(llVecDist(llGetPos(), llDetectedPos(num))) , llKey2Name(owner) , uuid];
//llOwnerSay("RESOLVED name - adding data");
} } } } timer() { gDataList = llListSort(gDataList, gStride, TRUE); integer c = (gDataList != [])-1; //magic while(c>-1) { gLink = (++gLink)%gPrims;
//llOwnerSay((string)(gLink+1));
list chunk = llList2List(gDataList, c-(gStride-1), c); llMessageLinked(gLink+1, 7 ,(string)llList2Integer(chunk, 0)+"m]" +"\t Owner:"+(string)llList2String(chunk, 1) +"\t Object:"+(string)llKey2Name(llList2String(chunk, 2)) , "" );
//llMessageLinked(LINK_SET,7,(string)num + "|" + text,""); //llOwnerSay(llList2CSV(llList2List(gDataList, c-(gStride-1), c)));
c-=gStride; } } dataserver(key queryid, string data) { integer index = llListFindList(gQueryList, [queryid]); if (-1<index) { key uuid = llList2Key(gQueryList, index+1); index = llListFindList(gDataList, [uuid]); if (-1<index) { gDataList = llListReplaceList(gDataList, [ llRound( llVecDist(llGetPos(),llList2Vector(llGetObjectDetails(uuid, ([OBJECT_POS])), 0)) ) , data, uuid], index-(gStride-1), index );
//llOwnerSay("DATASERVER returned name - adding data");
} } }
} //=========================================================================
<lsl>