Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string pass=""; //"1211"; // 1211"; // "" se è la prima tappa, nessuna password richiesta
- string nextpass="5688";
- string indovinello = "QUALE E' LA CAPITALE DELLA FRANCIA?";
- list risposte = [ "ROMA","*PARIGI","LONDRA" ];
- string indizio = "Il prossimo quiz lo trovi dietro i fiori verdi";
- list regali = [ "Oro","Argento","Bronzo" ]; // "" se non c'è
- list uuids; // avatarid + tentativi + risultato
- integer indicegiusto;
- integer ascolto;
- key avatar;
- string stato;
- integer listener=0;
- string occupato;
- string ipass;
- list avatars;
- integer found;
- integer tentativi;
- integer risultato;
- mostra(string name)
- {
- llSetText(llGetObjectName()+"\n ("+name+")",<1,1,1>,1);
- }
- faidomanda()
- {
- mostra(occupato+" ?");
- string scelte=""; list bottoni=[];
- integer i;
- for(i=0;i<llGetListLength(risposte);i++)
- {
- string r=llList2String(risposte,i);
- if(llGetSubString(r,0,0)=="*")
- {
- indicegiusto=i;
- r=llGetSubString(r,1,-1);
- }
- scelte+="\n"+(string)(i+1)+":"+r;
- bottoni+= [ (string)(i+1) ];
- }
- llDialog(avatar,indovinello+scelte+"\n Tentativo: "+(string)(tentativi+1),bottoni,1);
- stato="risposta";
- llSetTimerEvent(30);
- }
- tastierino()
- {
- llDialog(avatar,"Digita PWD\n<"+ipass+">", ["<+","0","<Invio>","1","2","3","4","5","6","7","8","9"], 1);
- llSetTimerEvent(10);
- stato="chiave";
- }
- reset()
- {
- llSetTimerEvent(0);
- llListenRemove(listener);
- listener=0;
- mostra("");
- stato="pronto";
- }
- okayprossimoindizio()
- {
- llDialog(avatar,"RISPOSTA GIUSTA!\nPROSSIMA PASS: "+nextpass+"\nPROSSIMO INDIZIO: \n"+indizio,["OK"],1);
- reset();
- }
- default
- {
- state_entry()
- {
- mostra("");
- stato = "pronto";
- llListen(100,"",llGetOwner(),"");
- }
- touch_start(integer count)
- {
- if(listener!=0) return;
- ipass="";
- avatar=llDetectedKey(0);
- found=llListFindList(uuids,[avatar]);
- if(found>=0)
- {
- tentativi=llList2Integer(uuids,found+2);
- risultato=llList2Integer(uuids,found+3);
- }
- else
- {
- tentativi=0;
- risultato=0;
- uuids+=[avatar,llDetectedName(0),0,0];
- found=llGetListLength(uuids)-4;
- }
- if(risultato==1)
- {
- okayprossimoindizio();
- return;
- }
- occupato=llDetectedName(0);
- llListen(1,"",avatar,"");
- if(pass=="")
- {
- faidomanda();
- return;
- }
- mostra(occupato+" ! ");
- tastierino();
- }
- listen(integer channel, string name, key id, string str)
- {
- if(channel==100)
- {
- if(str=="RESET")
- {
- llOwnerSay("Reset");
- llResetScript();
- return;
- }
- if(str=="LIST")
- {
- integer i;
- for(i=0;i<llGetListLength(uuids);i+=4)
- {
- llOwnerSay(llList2String(uuids,i+1)+": Tentativi "+(string)llList2String(uuids,i+2)+" risultato "+(string)llList2String(uuids,i+3));
- }
- }
- }
- if(stato=="chiave")
- {
- if(str=="<+"){
- if(llStringLength(ipass)>0)
- if(llStringLength(ipass)==1) ipass="";
- else
- ipass=llGetSubString(ipass,0,-2);
- tastierino();
- return;
- }
- if(str=="<Invio>")
- {
- if(ipass==pass)
- {
- faidomanda();
- return;
- }
- else
- {
- mostra(occupato+" :(");
- llDialog(avatar,"NON E' LA PAROLA CHIAVE GIUSTA",["OK"],-1);
- reset();
- return;
- }
- }
- //llOwnerSay("chiave");
- ipass=ipass+str;
- tastierino();
- return;
- }
- if(stato=="risposta"){
- tentativi++;
- if( (integer)(str) == indicegiusto+1)
- {
- mostra(occupato+" :)");
- string regalo=llList2String(regali,tentativi-1);
- if(regalo!="") {
- llSay(0,"Consegnato "+regalo+" a "+occupato);
- llGiveInventory(avatar,regalo);
- }
- uuids=llListReplaceList(uuids,[avatar, occupato, tentativi, 1 ],found,found+3);
- okayprossimoindizio();
- return;
- }
- else {
- mostra(occupato+" :(");
- uuids=llListReplaceList(uuids,[avatar,occupato,tentativi, 0 ],found,found+3);
- llDialog(avatar,"RISPOSTA SBAGLIATA!\nPUOI RIPROVARE :)",["OK"],1);
- reset();
- return;
- }
- }
- }
- timer()
- {
- llDialog(avatar,"TEMPO SCADUTO",["OK"],1);
- reset();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement