Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer LEN=4;
- string indovina;
- string simboli="1234567890"; // "♠♣♦♥";
- integer tentativi=0;
- list storia=[];
- key avatar;
- default
- {
- state_entry()
- {
- integer i; for(i=0;i<LEN;i++)
- {
- integer p=(integer)llFrand(llStringLength(simboli));
- //llSay(0,(string)p);
- indovina+=llGetSubString(simboli,p,p);
- simboli=llDeleteSubString(simboli,p,p);
- }
- llSay(0, "Sequenza scelta: "+indovina);
- llListen(1,"",NULL_KEY,"");
- }
- touch_start(integer count)
- {
- avatar=llDetectedKey(0);
- llTextBox(avatar,"Indovina ",1);
- }
- listen(integer channel, string name, key k, string str)
- {
- integer i;
- if(llStringLength(str)!=LEN) {
- llSay(0,"almeno "+(string)LEN+" numeri");
- return;
- }
- tentativi++; integer tori=0; integer mucche=0;
- for(i=0;i<LEN;i++)
- {
- if(llGetSubString(indovina,i,i)==llGetSubString(str,i,i))
- {
- tori++;
- }
- else
- {
- integer j;
- for(j=0;j<LEN;j++)
- {
- if(llGetSubString(indovina,j,j)==llGetSubString(str,i,i))
- {
- mucche++;
- }
- }
- }
- }
- if(tori==LEN){
- llSay(0,"Hai indovinato in "+llGetListLength(storia));
- llResetScript();
- return;
- }
- string esito="Tori: "+(string)tori+" Mucche: "+(string)mucche;
- storia+=["\n"+str+":"+esito];
- llSay(0,"Tori: "+(string)tori+" Mucche: "+(string)mucche);
- llTextBox(avatar,"Indovina "+llList2CSV(storia),1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement