1. Diese Seite verwendet Cookies. Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies. Weitere Informationen
  2. Bitte schaltet eure Ad Blocker aus. SLinfo kann nur betrieben werden, wenn es durch Werbung Einnahmen erzielt. Vielen Dank!!
    Information ausblenden
  3. Wir freuen uns, wenn du dich in unserem Forum anmeldest. Bitte beachte, dass die Freigabe per Hand durchgeführt wird (Schutz vor Spammer). Damit kann die Freigabe bis zu 24 Stunden dauern.
    Information ausblenden

Begrüßungs HUD z.B. für Clubs

Dieses Thema im Forum "Scripting" wurde erstellt von Archon Short, 18. November 2014.

  1. Archon Short

    Archon Short Administrator Mitarbeiter

    Beiträge:
    5.185
    Zustimmungen:
    756
    Punkte für Erfolge:
    124
    Nachdem wir nun ja schon den Scanner nebst Sortierung nach zeitlicher Anwesenheit hatten,
    kommt von mir diesmal ein möglicher Anwendungsbereich.

    Hier das fertige Script dazu.
    Einfach in ein Prim, ans HUD und dann loslegen.


    Code:
    // Integer of the scannerrange
    integer RANGE=40;
    // Integer of the actual sentence
    integer I_satz = 0;
    // Communication channel
    integer I_kanal;
    // Temporary List of the avatars in the region
    list agent=[];
    // List for the sentences
    list L_TEXT = [];
    // Temporary Keylist
    list plist;
    // Temporary Namelist
    list n_list;
    // Ownerkey, getting at the start of the script
    key     K_Owner;
    // Temporary Key of the person to greet
    key K_temp = NULL_KEY;
    // Temorary Name of the person to greet
    string S_temp_name = "";
    // String for the Text said 
    string text;
    // Toggled String to manage how the script would communicate
    string S_how_say = "open chat";
    // Ownername, getting at the start of the script
    string S_Ownername;
    // Often needed stuff in functions to reduce scriptweight
    say_to(key kk_K, string ss_S)   {   llRegionSayTo(kk_K,0,ss_S);             }
    owner_say(string ss_S)          {   llOwnerSay(ss_S);                       }
    open_say(string ss_S)           {   llSay(0,ss_S);                          }
    dialog(string ss_S,list ll_L)   {   llDialog(K_Owner,ss_S,ll_L,I_kanal);    }
    textbox(string ss_S)            {   llTextBox(K_Owner,ss_S,I_kanal);        }
    // replacing ##name##  with the name of the person to greet
    string strReplace(string str)
    {   
        return llDumpList2String(llParseStringKeepNulls((str = "") + str, ["##name##"], []), S_temp_name);
    }
    // Generating chattext
    generate_text()
    {
        text = strReplace(llList2String(L_TEXT,I_satz)) ;
        text = "/me of "+S_Ownername+": "+ text;
        if(S_how_say == "open chat")    open_say(text);
        else                        {   say_to(K_temp,text);    owner_say(text);    }
        dialog("What do you want to do next?\nNEXT - next sentence\nNEW_PERSON - new person to greet\nRESET - reset the script to enter new text",["NEXT","NEW_PERSON","RESET"]);
    }
    // Scanning for Avatars in Range
    scan()
    {
        list tmpagent = llGetAgentList(AGENT_LIST_PARCEL, []);
        list newagent=[];
        plist=[];
        llSetTimerEvent(10);
        integer i;
        for (i=0; i < llGetListLength(tmpagent); ++i) 
        {
            key id=llList2Key(tmpagent,i);
            integer index=llListFindList(agent,[id]);
            if (index<0) newagent+=1;
            else newagent+=llList2Integer(agent,index-1)+1;
            newagent+=id;
        }
        agent=llListSort(newagent, 2, TRUE);
        vector pos=llGetPos();
        string res=" "; // nicht ""
        for (i=1; i < llGetListLength(agent); i+=2) 
        {
            string name=llGetDisplayName(llList2Key(agent,i));
            if (name!="") 
            {
                list tmp=llGetObjectDetails(llList2Key(agent,i), [OBJECT_POS] );
                float dist=llVecDist(pos,llList2Vector(tmp,0));
                if (dist<=RANGE && llList2Key(agent,i) != K_Owner) 
                {
                    res+=llList2String(agent,i-1)+" "+name+"\n";
                    plist += llList2Key(agent,i);
                }
            }
        }
        llSetText(res,<1,1,1>,1);
    }
    
    default
    {
        state_entry()
        {
            K_Owner = llGetOwner();
            S_Ownername = llGetDisplayName(K_Owner);
            llSetText("",<1,1,1>,1);
            owner_say("Hello "+S_Ownername+", you´re wearing the "+llGetObjectName()+".\nTouch me to beginn with the configuration ");
            I_kanal = llFloor(llFrand(999999)-11111111);
            llListen(I_kanal,"","","");
        }
    
        touch_start(integer total_number)
        {
            if(llGetListLength(L_TEXT) == 0) textbox("Hello, enter here a welcome message.\nReplace the persons name in the message with ##name##"); 
            else dialog("What do you want to do?\nTOGGLE_SAY to change how the person will read the text\nopen chat = public\nprivate message = message to you and the greeted person only\nActual it´s: "+S_how_say+"\nADD_LINE to add more text\nFINISH to start the greeter\nRESET to start config again" ,["ADD_LINE","FINISH","RESET","TOGGLE_SAY"]); 
        }
        
        listen(integer channel, string name, key id, string message)
        {
            if(message == "ADD_LINE")                                   textbox("Hello, enter here a welcome message.\nReplace the persons name in the message with ##name##");
            else if(message == "RESET")                                 llResetScript();
            else if(message == "TOGGLE_SAY")
            {
                if(S_how_say == "open chat")    S_how_say = "private message";
                else                            S_how_say = "open chat";
                dialog("What do you want to do?\nTOGGLE_SAY to change how the person will read the text\nopen chat = public\nprivate message = message to you and the greeted person only\nActual it´s: "+S_how_say+"\nADD_LINE to add more text\nFINISH to start the greeter\nRESET to start config again" ,["ADD_LINE","FINISH","RESET","TOGGLE_SAY"]);  
            }
            else if(message == "FINISH" && llGetListLength(L_TEXT) > 0) state running;
            else                                                        
            {
                L_TEXT = L_TEXT + [message];
                dialog("What do you want to do?\nTOGGLE_SAY to change how the person will read the text\nopen chat = public\nprivate message = message to you and the greeted person only\nActual it´s: "+S_how_say+"\nADD_LINE to add more text\nFINISH to start the greeter\nRESET to start config again" ,["ADD_LINE","FINISH","RESET","TOGGLE_SAY"]);  
            }
        }
        on_rez(integer k){llResetScript();}
    }
    
    
    
    
    state running 
    {
    
        state_entry() 
        {
            owner_say("FREE MEMORY : "+(string)(llGetMemoryLimit()-llGetUsedMemory()));
            llSetText(" ",<1,1,1>,1);
            llSetTimerEvent(0.1);
            llListen(I_kanal,"","","");
            owner_say("I´m now ready to greet some people");
        }
    
        timer() {   scan(); }
        touch_start(integer total_number)
        {
            llSetTimerEvent(30);
            integer i;
            n_list = [];
            for(i=0;i<9;i++)
            {
                if(i<=llGetListLength(plist)+1)
                {
                    if(llList2Key(plist,i) == K_Owner)return;
                    string dname = llGetDisplayName(llList2Key(plist,i));
                    if(dname != "")         
                    {
                        if(llGetListLength(n_list)>0)   n_list = n_list + [dname];
                        else                            n_list = [dname];
                    }
                }
            }
            dialog("Who do you want to greet?\nOr would you reset the script to enter new text?",["RESET"]+n_list);
        }
        listen(integer channel, string name, key id, string message)
        {
            if(message == "RESET")llResetScript();
            else if(message == "NEW_PERSON")
            {
                scan();
                K_temp = NULL_KEY;  S_temp_name = "";   I_satz = 0; n_list = [];
                integer i;
                for(i=0;i<9;i++)
                {
                    if(i<=llGetListLength(plist)+1)
                    {
                        if(llList2Key(plist,i) == K_Owner)return;
                        string dname = llGetDisplayName(llList2Key(plist,i));
                        if(dname != "")         
                        {
                            if(llGetListLength(n_list)>0)   n_list = n_list + [dname];
                            else                            n_list = [dname];
                        }
                    }
                }
                dialog("Who do you want to greet?\nOr would you reset the script to enter new text?",["RESET"]+n_list);
            }
            else if(message == "NEXT")
            {
                scan();
                if(I_satz < llGetListLength(L_TEXT)-1)
                {
                    I_satz = I_satz + 1;
                    generate_text();
                }
            }
            else                                                        
            {
                llSetTimerEvent(20);
                S_temp_name = message;
                integer ii = llListFindList(n_list, [message]);
                K_temp = llList2Key(plist,ii);
                I_satz = 0;
                generate_text();
            }
        }
        changed(integer change) {   if(change & CHANGED_OWNER)llResetScript();  }
    }
    Falls noch jemand Ideen zu Vereinfachung hat, dann her damit :)