Open Prim Animator/Frame Labels
< Open Prim Animator
Jump to navigation
Jump to search
Revision as of 06:18, 14 December 2011 by SignpostMarv Martin (talk | contribs) (Committing changes made to OPA made over the past year at work)
<lsl> getRecordedSnapshots(){
llMessageLinked(LINK_THIS,-1,"XDrecordedSnapshots",NULL_KEY);
}
string notecard = "OPA-Frame-Labels"; string contents; list _contents; list multithread_fetch = []; key nlq;
export_string(string _export_string){
integer s=1000; while(llStringLength(_export_string) > s){ llOwnerSay(llGetSubString(_export_string,0,(s-1))); _export_string = llGetSubString(_export_string,s,-1); } if(llStringLength(_export_string) > 0){ llOwnerSay(_export_string); }
}
integer recordedSnapshots = 0; key op_change_frame = "1071f377-8623-4ed3-acc1-d30cabb4524a";
default{
state_entry(){ integer type = llGetInventoryType(notecard); if(type == INVENTORY_NONE){ llOwnerSay("Notecard not found"); }else if(type != INVENTORY_NOTECARD){ llOwnerSay("Inventory item found with name of notecard, but it is not a notecard"); }else{ state num_lines; } }
changed(integer c){ if(c & CHANGED_INVENTORY && llGetInventoryType(notecard) == INVENTORY_NOTECARD){ state num_lines; } }
state_exit(){
// llOwnerSay("Notecard found, parsing");
}
}
state num_lines{
state_entry(){ nlq = llGetNumberOfNotecardLines(notecard); }
dataserver(key q, string m){ if(q == nlq){ integer i; integer j = (integer)m; if(j < 1){ contents = ""; state done_reading; } list k = []; // declaring list k = []; isn't exactly necessary, you could do list k; list l = []; for(i=0;i<j;++i){ // since we don't have the concept of transactions in LSL scripts, we're going to build up these lists separately k += [NULL_KEY]; l += [NULL_KEY]; } _contents = k; // this is where we do the atomic writes due to lack of transactions on variables multithread_fetch = l; // this is where we do the atomic writes due to lack of transactions on variables k = []; // cleaning up the local variable on purpose in case the LSL VM executing this script is inefficient l = []; // cleaning up the local variable on purpose in case the LSL VM executing this script is inefficient state mtf; } }
}
state mtf{
state_entry(){ integer i; integer j=llGetListLength(multithread_fetch); for(i=0;i<j;++i){ multithread_fetch = llListReplaceList(multithread_fetch,[llGetNotecardLine(notecard,i)],i,i); // sets the notecard fetching away } }
dataserver(key q, string m){ integer i = llListFindList(multithread_fetch,[q]); if(i >= 0){ _contents = llListReplaceList(_contents,[m],i,i); // the traditional method of notecard fetching in LSL is single-threaded, getting one line at a time } if(llListFindList(_contents,[NULL_KEY]) == -1){ // since we started out with a NULLL_KEY-filled list, if there aren't any NUL_KEY in the list then we know it's done. caveat scriptor: since key and string types are interchangeable contents = llDumpList2String(_contents,"\n"); state done_reading; } }
state_exit(){ _contents = []; multithread_fetch = []; }
}
state done_reading{
state_entry(){ _contents = llParseString2List(contents, ["\n"],[]);
// llOwnerSay((string)llGetListLength(_contents) + " frame labels found");
getRecordedSnapshots(); }
link_message(integer s, integer n, string m, key i){ if(m == "XDrecordedSnapshots" && n >= 0){ recordedSnapshots = n; if(recordedSnapshots == 1){ llMessageLinked(LINK_THIS,0,"XDplay",NULL_KEY); } }else if(i == op_change_frame){ integer frame = llListFindList(_contents,[m]); if(frame >= 0){ llMessageLinked(LINK_THIS,frame + 1,"XDshow",NULL_KEY); } } }
changed(integer c){ if(c & CHANGED_INVENTORY){ llResetScript(); } }
} </lsl>