Advertisement
salahzar

controllore metodica (ricetta) chimica

May 2nd, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer line;
  2. string notecard;
  3. list steps;
  4. list done;
  5. integer index;
  6. integer starting;
  7.  
  8. integer listener;
  9.  
  10. debug(string str) { llOwnerSay(str);}
  11.  
  12. default
  13. {
  14.     state_entry()
  15.     {
  16.         notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
  17.         line=0; done=[];
  18.         llGetNotecardLine(notecard,line);
  19.     }
  20.     dataserver(key id,string data)
  21.     {
  22.         if(data!=EOF){
  23.             steps+=[data];
  24.             line++;
  25.             llGetNotecardLine(notecard,line);
  26.             return;
  27.         }
  28.         state ready;
  29.     }
  30. }
  31. state ready
  32. {
  33.     state_entry()
  34.     {
  35.         starting=llGetUnixTime();
  36.         llSetColor(<1,1,1>,ALL_SIDES);
  37.         llSay(0,"Ready "+(string)(line)+" steps ");
  38.         index=0; done=[]; llSetText("Inizia esperimento",<1,1,1>,1);
  39.         llListen(100,"",NULL_KEY,"");
  40.     }
  41.     touch_start(integer count)
  42.     {
  43.         key id=llDetectedKey(0);
  44.         if(index==0) {
  45.             starting=llGetUnixTime();
  46.            // llSay(0,"starting is "+(string)starting);
  47.         }
  48.         listener=llListen(-1,"",id,"");
  49.         llSetTimerEvent(10);
  50.         llDialog(id,"Scegli",["SCALDA","FILTRA","GHIACCIA","VERSA","MESCOLA","RESET" ],-1);
  51.     }
  52.     timer()
  53.     {
  54.         llSetTimerEvent(0);
  55.         listener=-1;
  56.        llSay(0,"timeout");
  57.     }
  58.    
  59.     listen(integer channel,string name,key id,string str)
  60.     {
  61.         llSetTimerEvent(0);
  62.         llListenRemove(listener);
  63.         if(str=="RESET"){
  64.            llResetScript();
  65.             return;
  66.         }
  67.        debug("ricevuto "+str+" sul canale "+(string)channel);
  68.         string right=llStringTrim(llList2String(steps,index),STRING_TRIM_TAIL);
  69.       //  debug("confronto "+str+" con "+right);
  70.        
  71.         if(right==str)
  72.         {
  73.             index++;
  74.            
  75.             if(index>=llGetListLength(steps))
  76.             {
  77.                 llSay(0,"Complimenti, hai prodotto "+notecard+" in "+(string)(llGetUnixTime()-starting)+" secondi");
  78.                 llResetScript();
  79.                 return;
  80.             }
  81.             llSay(0,"il passo è giusto, vai avanti");
  82.             llSetColor(<0,1,0>,ALL_SIDES);
  83.             done+=[ (string)index+")"+str ];
  84.             llSetText(llDumpList2String(done,"\n"),<1,1,1>,1);
  85.            
  86.             return;
  87.         }
  88.         llSetColor(<1,0,0>,ALL_SIDES);
  89.         llSay(0,"Mi dispiace, hai sbagliato devi ricominciare da capo");
  90.         llResetScript();
  91.        
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement