Guest User

Untitled

a guest
Apr 18th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ~Memory
  2. //MLP MULTI-LOVE-POSE V1.2 - Copyright (c) 2006, by Miffy Fluffy (BSD License)
  3. integer i;
  4. integer j;
  5. integer line;
  6. integer p;
  7. list poses;
  8. list positions;
  9.  
  10. default {
  11.     state_entry() {
  12.         llOwnerSay("Memory is empty, loading notecard: .POSITIONS");
  13.         llGetNotecardLine(".POSITIONS",0);          //read first line of positions notecard
  14.     }
  15.      dataserver(key query_id, string data) {                                
  16.         if (data == EOF) state on;
  17.         i = llSubStringIndex(data,"{");             //split name from positions, remove junk
  18.         j = llSubStringIndex(data,"} <");
  19.         if (i != -1 && j != -1) {
  20.             //poses += [ llGetSubString(data, i+1, j - 1) ];
  21.             //positions += [ llGetSubString(data, j+2, -1) ];
  22.             poses = [ llGetSubString(data, i+1, j - 1) ] + (poses = []) + poses;            //saves memory
  23.             positions = [ llGetSubString(data, j+2, -1) ] + (positions = []) + positions;   //saves memory
  24.             ++p;  
  25.         }
  26.         ++line;
  27.         llGetNotecardLine(".POSITIONS",line);       //read next line of positions notecard
  28.     }
  29.     state_exit() {
  30.         llOwnerSay((string)p+" positions stored in memory ("+llGetScriptName()+": "+(string)llGetFreeMemory()+" bytes free)");
  31.         if (p < 2) {
  32.             poses = [ "stand","default" ];
  33.             positions = [ "<-0.7,0.0,0.9> <0.0,0.0,0.0> <0.7,0.0,0.9> <0.0,0.0,-180.0>",
  34.                           "<-0.7,0.0,0.7> <0.0,0.0,0.0> <0.7,0.0,0.7> <0.0,0.0,-180.0>" ];
  35.             p = 2;
  36.         }
  37.         llMessageLinked(LINK_THIS,2,"OK",NULL_KEY); //msg to menu, in case it's waiting for loading
  38.     }
  39. }
  40. state on {
  41.    
  42.     link_message(integer from, integer num, string str, key dkey) {
  43.         if (str == "PRIMTOUCH"){
  44.             return;
  45.         }
  46.         if (num != 1) return;        
  47.         if (str == "OK?") {                                 //question from menu, before loading menu
  48.             llMessageLinked(from,2,"OK",NULL_KEY);          //answer to menu
  49.         } else if (str == "LOADED") {                       //msg from menu: loaded
  50.             llMessageLinked(from,3,"LOADED",dkey);          //forward msg to pos
  51.         } else if (str == "DUMP") {
  52.             llOwnerSay("_______________________________________________________________________________");
  53.             llOwnerSay("");
  54.             llOwnerSay("Copy to notecard: .POSITIONS");
  55.             llOwnerSay("_______________________________________________________________________________");
  56.             llOwnerSay("");
  57.             //for (i=0; i < p; ++i) llOwnerSay("{"+llList2String(poses,i)+"} "+llList2String(positions,i));
  58.             for (i=p - 1; i>=0; --i) llOwnerSay("{"+llList2String(poses,i)+"} "+llList2String(positions,i));
  59.         } else {
  60.             i = llListFindList(poses,[ str ]);              //find pose
  61.             if (llGetSubString((string)dkey,0,0) == "<") {  //SAVE
  62.                 if (i != -1) {
  63.                     positions = llListReplaceList(positions,[ (string)dkey ],i,i);
  64.                     llOwnerSay("{"+str+"} position updated in memory");
  65.                 } else {
  66.                     //poses += [ str ];
  67.                     //positions += [ (string)dkey ];
  68.                     poses = [ str ] + (poses = []) + poses;                         //saves memory
  69.                     positions = [ (string)dkey ] + (positions = []) + positions;    //saves memory
  70.                     ++p;
  71.                     llOwnerSay("{"+str+"} position added to memory");
  72.                 }
  73.                 llOwnerSay("("+llGetScriptName()+": "+(string)llGetFreeMemory()+" bytes free, "+(string)p+" positions)");
  74.             } else {                                        //LOAD
  75.                 //if (i == -1) i = 0;                                         //not found, send default (-1 if save mem)    
  76.                 llMessageLinked(from,3,llList2String(positions,i),dkey);    //msg to pos: sent position
  77.             }
  78.         }        
  79.     }
  80. }
Add Comment
Please, Sign In to add comment