SHARE
TWEET

Converter: MLP RLV/LG to PMAC

AineCaoimhe Jul 7th, 2017 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Conversion Utility MLP RLV & LG to PMAC 2.5
  2. // by Aine Caoimeh (c. LACM) June 2017
  3. //
  4. // This script is intended to help people who have a fully functioning MLP system that include correct/accurate RLV data and Lockguard data notecards.
  5. // No attempt is made to validate the data, nor is there any other error-checking at all
  6. // DO NOT EVER work on the original version of your item...make a copy and convert it. That way if something goes wrong you will still have your original.
  7. //
  8. // This script has been given only limited testing on RLV/LG items I know are working under the current version. I cannot promise that it will work on
  9. /// a setup that you have. You may need to modify the script to match your own system.
  10. //
  11. // INSTRUCTIONS
  12. // 1. FIRST CONVERT THE OBJECT FROM MLP TO PMAC USING SETH'S SCRIPT
  13. // 2. TEST TO MAKE SURE ALL POSES ARE WORKING
  14. // 3. MAKE A COPY OF THE CONVERTED ITEM
  15. // 4. DROP THIS SCRIPT INTO THE COPY AND IT WILL AUTOMATICALLY TRY TO FIND AND CONVERT THE ".RVL" AND ".CHAINDATA" NOTECARDS, IF FOUND
  16. //
  17. // Note:
  18. // Data is not cross-checked or validated. If it's broken in the originala it won't get magially fixed after conversion or could even break the PMAC setup
  19. // Data suppled for missing animations is ignored...no effort is made to match it to anything else nor are you told what is skipped
  20. // For any pose, if there is any date for one position and no data for other positions, the other positions are given null entries to ensure valid syntax of those entries
  21. // The is NO CHECK on the RLV or LG data or syntax supplied...if it's wrong in your original it will be in the converted version too
  22. // The original notecards are deleted from the system once complete and the PMAC notecards are updated
  23. // Any animation that has no data is not given zeroed-out data to you may need to do that (ie if your setup was messed up like that in MLP it will still be messed up in PMAC)
  24. //
  25. // RLV command chains are built using "@" prior to each command to ensure compatibility with all RLV relays, etc; even though that's a bit too spammy. If you wish to use
  26. // the v1.10+ chains you can simply change this script to assemble the strings that way, or else do a global search & replace of ",@" >> "," in the new menu notecard.
  27. //
  28. // THIS SCRIPT IS SUPPLIED AS IS PURELY AS SOMETHING THAT HAS THE POTENTIAL TO HELP YOU CONVERT A SYSTEM. I DO NOT OFFICIALLY SUPPORT IT NOR DO I PLAN TO
  29. // EXPAND IT ANY FURTHER TO COVER SPECIAL CASES OR OTHER VERSIONS. YOU'RE WELCOME TO WRITE THOSE VARIATIONS YOURSELF.
  30. // IT IS INTENDED FOR CREATORS WHO ARE FAMILIAR WITH PMAC AND MLP OR PEOPLE WILLING TO EDUCATE THEMSELVES ON THOSE SYSTEMS TO RESOLVE ANY ISSUES THAT CROP UP
  31. //
  32. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  33. // THERE ARE NO USER SETTINGS....DON'T CHANGE ANYTHING UNLESS YOU KNOW WHAT YOU'RE DOING!
  34. //
  35. integer debug=FALSE;    // if set to TRUE don't delete scrip or old cards and be more verbose...but then don't let this script run a second time or it will completely ruin your menu notecard
  36. string rlvCardName=".RLV";  // expected notecard name where the RLV data is sourced
  37. string lgCardName=".CHAINDATA"; // ditto for LG chain data
  38. list rlvData;
  39. list lgData;
  40. list menucards;
  41.  
  42. doGatherRLV()
  43. {
  44.     rlvData=[];
  45.     if (llGetInventoryType(rlvCardName)!=INVENTORY_NOTECARD)
  46.     {
  47.         llOwnerSay("Unable to located the RLV data notecard specified: "+rlvCardName);
  48.         return;
  49.     }
  50.     else llOwnerSay("Reading in RLV data");
  51.     list rawData=llParseString2List(osGetNotecard(rlvCardName),["\n"],[]);
  52.     integer i;
  53.     while (i<llGetListLength(rawData))
  54.     {
  55.         string line=llList2String(rawData,i);
  56.         line = llStringTrim(line,STRING_TRIM);
  57.         if (llGetSubString(line,0,0)!="/")
  58.         {
  59.             list thisLineData=llParseString2List(line,["|"],[]);
  60.             rlvData=[]+rlvData+[llStringTrim(llList2String(thisLineData,0),STRING_TRIM)];
  61.             string trimmed=llStringTrim(llList2String(thisLineData,1),STRING_TRIM);
  62.             if (trimmed=="*") rlvData=[]+rlvData+["*"];
  63.             else rlvData=[]+rlvData+[(integer)trimmed];
  64.             integer c=2;
  65.             while (c<llGetListLength(thisLineData))
  66.             {
  67.                 thisLineData=[]+llListReplaceList(thisLineData,[llStringTrim(llList2String(thisLineData,c),STRING_TRIM)],c,c);
  68.                 c++;
  69.             }
  70.             rlvData=[]+rlvData+[llDumpList2String(llList2List(thisLineData,2,-1),",")];
  71.         }
  72.         i++;
  73.     }
  74.     // can't assemble until we know how many poses so leave in this state for now
  75.     if (debug) llOwnerSay("RLV Data:\n"+llDumpList2String(rlvData,"|"));
  76. }
  77.  
  78. doGatherLG()
  79. {
  80.     lgData=[];
  81.     if (llGetInventoryType(lgCardName)!=INVENTORY_NOTECARD)
  82.     {
  83.         llOwnerSay("Unable to located the lockguard data notecard specified: "+lgCardName);
  84.         return;
  85.     }
  86.     else llOwnerSay("Reading in Lockguard data");
  87.     list rawData=llParseString2List(osGetNotecard(lgCardName),["\n"],[]);
  88.     integer i;
  89.     while (i<llGetListLength(rawData))
  90.     {
  91.         string line=llList2String(rawData,i);
  92.         line = llStringTrim(line,STRING_TRIM);
  93.         if (llGetSubString(line,0,0)!="/")
  94.         {
  95.             list thisLineData=llParseString2List(line,["|"],[]);
  96.             lgData=[]+lgData+[llStringTrim(llList2String(thisLineData,0),STRING_TRIM)];
  97.             string trimmed=llStringTrim(llList2String(thisLineData,1),STRING_TRIM);
  98.             if (trimmed=="*") lgData=[]+lgData+["*"];
  99.             else lgData=[]+lgData+[(integer)trimmed];
  100.             lgData=[]+lgData+[llStringTrim(llList2String(thisLineData,2),STRING_TRIM)]+[llStringTrim(llList2String(thisLineData,3),STRING_TRIM)];
  101.         }
  102.         i++;
  103.     }
  104.     // can't assemble until we know how many poses so leave in this state for now
  105.     if (debug) llOwnerSay("LG Data:\n"+llDumpList2String(lgData,"|"));
  106. }
  107.  
  108. doGatherMenus()
  109. {
  110.     menucards=[];
  111.     integer i=llGetInventoryNumber(INVENTORY_NOTECARD);
  112.     while (--i>=0)
  113.     {
  114.         string name=llGetInventoryName(INVENTORY_NOTECARD,i);
  115.         if (llSubStringIndex(name,".menu")==0) menucards=[]+[name]+menucards;
  116.     }
  117.     llOwnerSay("Found "+(string)llGetListLength(menucards)+" menu notecards to check and update...");
  118. }
  119.  
  120. doDataIntegrate(string menucard)
  121. {
  122.     integer nameStarts=llSubStringIndex(menucard," ")+1;
  123.     integer posCount=(integer)(llGetSubString(menucard,7,nameStarts-3));
  124.     llOwnerSay("Processing menu: "+llGetSubString(menucard,nameStarts,-1));
  125.     list data=llParseString2List(osGetNotecard(menucard),["\n"],[]);
  126.     //data is LINE-SEPARATED
  127.     string newData;
  128.     integer i;
  129.     while (i<llGetListLength(data))
  130.     {
  131.         list thisLineData=llParseString2List(llList2String(data,i),["|"],[]);
  132.         string anName=llList2String(thisLineData,0);
  133.         string command=llList2String(thisLineData,1);
  134.         string rlvCommand;
  135.         string lgCommand;
  136.         if (command=="NO COM") command="";
  137.         else if (command=="NO_COM") command="";
  138.         // build new rlv command if a card exists at all
  139.         if (llGetListLength(rlvData)>0)
  140.         {
  141.             rlvCommand=""+"PAO_RLV_SEND{";
  142.             integer p;
  143.             while (p<posCount)
  144.             {
  145.                 integer indRLV=llListFindList(rlvData,[anName,p]);
  146.                 if(p>0) rlvCommand+="::";
  147.                 if (indRLV==-1) rlvCommand+="RLV_NO_COM";
  148.                 else rlvCommand+=llList2String(rlvData,indRLV+2);
  149.                 p++;
  150.             }
  151.             rlvCommand+="}";
  152.         }
  153.         // build new lockguard command if a card exists at all
  154.         if (llGetListLength(lgData)>0)
  155.         {
  156.             lgCommand="PAO_LOCK{";
  157.             integer q;
  158.             while (q<posCount)
  159.             {
  160.                 integer indLG=llListFindList(lgData,[anName,q]);
  161.                 if(q>0) lgCommand+="::";
  162.                 if (indLG==-1) lgCommand+="LOCK_NO_COM";
  163.                 else
  164.                 {
  165.                     // have to build this differently because LG commands are often multple lines for 1 position so we need to assemble by position as well
  166.                     lgCommand+=llList2String(lgData,indLG+2)+"="+llList2String(lgData,indLG+3);
  167.                     list remainingList=llList2List(lgData,indLG+4,-1);
  168.                     while (llListFindList(remainingList,[anName,q])>-1)
  169.                     {
  170.                         integer nextInd=llListFindList(remainingList,[anName,q]);
  171.                         lgCommand+="&&"+llList2String(remainingList,nextInd+2)+"="+llList2String(remainingList,nextInd+3);
  172.                         remainingList=[]+llDeleteSubList(remainingList,0,nextInd+3);
  173.                     }
  174.                 }
  175.                 q++;
  176.             }
  177.             lgCommand+="}";
  178.         }
  179.         command=""+lgCommand+rlvCommand+command;
  180.         // updated command is now built -- update in data
  181.         thisLineData=[]+llListReplaceList(thisLineData,[command],1,1);
  182.         // dump into new data
  183.         newData+=llDumpList2String(thisLineData,"|")+"\n";
  184.         i++;
  185.     }
  186.     // replace with the new data and while we're at it, update the list of menu cards not yet proceessed
  187.     menucards=[]+llDeleteSubList(menucards,0,0);
  188.     llRemoveInventory(menucard);
  189.     llSleep(0.25);  // evil sleep required to give inventory removal time to execute
  190.     osMakeNotecard(menucard,newData);
  191. }
  192.  
  193. cleanUp()
  194. {
  195.     if (debug) llOwnerSay("DEBUG MODE: note removing notecards");
  196.     else
  197.     {
  198.         if (llGetInventoryType(rlvCardName)==INVENTORY_NOTECARD) llRemoveInventory(rlvCardName);
  199.         if (llGetInventoryType(lgCardName)==INVENTORY_NOTECARD) llRemoveInventory(lgCardName);
  200.         llRemoveInventory(llGetScriptName());
  201.     }
  202. }
  203.  
  204. doConversion()
  205. {
  206.     doGatherRLV();
  207.     doGatherLG();
  208.     doGatherMenus();
  209.     if (llGetListLength(rlvData)+llGetListLength(lgData)<1) llOwnerSay("Unable to retrieve any RLV or Lockguard data....aborting");
  210.     else { while (llGetListLength(menucards)>0) { doDataIntegrate(llList2String(menucards,0)); } }
  211.     cleanUp();
  212. }
  213.  
  214. default
  215. {
  216.     state_entry()
  217.     {
  218.         llOwnerSay("Initiating MLP RLV/LG conversion....please wait...");
  219.         doConversion();
  220.     }
  221. }
RAW Paste Data
Top