Difference between revisions of "Open Prim Animator/Import-Export"
Jump to navigation
Jump to search
(Uploading the import/export script) |
m (whoops, meant to make the commit sans-incomplete docs :D) |
||
Line 11: | Line 11: | ||
* accidentally delinking objects etc. | * accidentally delinking objects etc. | ||
* Once an import has been parsed, the script checks it against | * Once an import has been parsed, the script checks it against | ||
*/ | |||
list names; | list names; | ||
list pos; | list pos; |
Revision as of 03:15, 14 December 2011
<lsl> //! @brief Animation export script for Open Prim Animator http://wiki.secondlife.com/wiki/Open_Prim_Animator /**
- @author SignpostMarv
- /
//! Storing the names in exports allows us to remap links according to their current state /**
- we want to store the names because there are circumstances where the link order can change-
- TPV object import/export
- accidentally delinking objects etc.
- Once an import has been parsed, the script checks it against
- /
list names; list pos; list rot; list size;
key import = "6b78fcc8-e147-4105-99a6-ff19b4bf559d"; key export = "7c2ca168-2b64-4836-8727-8e62b78dbd44";
export_string(string _export_string){
integer s = 249; while(llStringLength(_export_string) > s){ llOwnerSay("\n" + llGetSubString(_export_string,0,(s-1))); _export_string = llGetSubString(_export_string,s,-1); } if(llStringLength(_export_string) > 0){ llOwnerSay("\n" + _export_string); }
}
string truncate_float(float foo){
if(foo == 0.0){ return "0"; }else if(foo == (float)((integer)foo)){ return (string)((integer)foo); } string bar = (string)foo; while(llGetSubString(bar,-1,-1) == "0"){ bar = llGetSubString(bar,0,-2); } if(llGetSubString(bar,-1,-1) == "."){ bar = llGetSubString(bar,0,-2); } return bar;
}
string truncate_vector(vector foo){
if(foo == ZERO_VECTOR){ return "<0,0,0>"; } string bar = "<"; bar += truncate_float(foo.x) + ","; bar += truncate_float(foo.y) + ","; bar += truncate_float(foo.z) + ">"; return bar;
}
string truncate_rotation(rotation foo){
if(foo == ZERO_ROTATION){ return "<0,0,0,1>"; } string bar = "<"; bar += truncate_float(foo.x) + ","; bar += truncate_float(foo.y) + ","; bar += truncate_float(foo.z) + ","; bar += truncate_float(foo.s) + ">"; return bar;
}
default{
link_message(integer s, integer n, string m, key k){ if(k == export){ integer i; integer j; if(n == 1){ names = llParseString2List(m,["|"],[]); }else if(n == 2){ pos = llParseString2List(m,["|"],[]); j=llGetListLength(pos); for(i=0;i<j;++i){ pos = llListReplaceList(pos,[(vector)llList2String(pos,i)],i,i); } }else if(n == 3){ rot = llParseString2List(m,["|"],[]); j=llGetListLength(rot); for(i=0;i<j;++i){ rot = llListReplaceList(rot,[(rotation)llList2String(rot,i)],i,i); } }else if(n == 4){ size = llParseString2List(m,["|"],[]); j=llGetListLength(size); for(i=0;i<j;++i){ size = llListReplaceList(size,[(vector)llList2String(size,i)],i,i); } } if(names != [] && pos != [] && rot != [] && size != []){
llOwnerSay("Exporting:"); export_string("rootscale:" + truncate_vector(llGetScale())); export_string("names:" + llDumpList2String(names,"|")); list bar = []; j= llGetListLength(pos); for(i=0;i<j;++i){ bar += truncate_vector(llList2Vector(pos,i)); } export_string("pos:" + llDumpList2String(bar,"|")); bar = []; for(i=0;i<j;++i){ bar += truncate_rotation(llList2Rot(rot,i)); } export_string("rot:" + llDumpList2String(bar,"|")); bar = []; for(i=0;i<j;++i){ bar += truncate_vector(llList2Vector(size,i)); } export_string("size:" + llDumpList2String(bar,"|")); bar = []; llMessageLinked(LINK_THIS,0,"XDmenu",NULL_KEY); llResetScript(); } }else if(k == import && n == -1){ llOwnerSay("importing"); integer i; integer j=llGetListLength(pos); for(i=0;i<j;++i){ llMessageLinked(s,i,llDumpList2String([llList2Vector(pos,i),llList2Rot(rot,i),llList2Vector(size,i)],"|"),import); } llMessageLinked(LINK_THIS,0,"XDmenu",NULL_KEY); llResetScript(); } }
} </lsl>