Difference between revisions of "Language Scanner"

From Second Life Wiki
Jump to navigation Jump to search
(Remove Copyright)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
[[Category:LSL_Library]]
[[Category:LSL_Library]]
<div style="padding-left: 0.3em">
<div style="padding-left: 0.3em;">
[[Teleporter_Anywhere]] | [[Ultimate_Radar]] | [[Language_Scanner]] | [[Visitor_Counter_Tracker]]
[[User:Luxen_Resident]] | [[Teleporter_Anywhere]] | [[Ultimate_Radar]] | [[Language_Scanner]] | [[Visitor_Counter_Tracker]]
</div>
</div>
==Zx Language Scanner==
<div id="box">
<div id="box">
<div style="padding: 0.5em 0.5em 1.5em">
==Summary==
Advanced language scanner to detect users language, distance and names on a Sim.
<div style="padding: 0.5em;">
With the hud menu, you can easily filter by language.
Advanced language scanner to detect users language, distance and names on a Sim.<br />
Useful to find who speak your language or who speak the language of your choice.
You can easily filter by language with the menu. Useful to find who speak your language.
Can be used with a translator as an addon or as a standalone tool.
 
* Copyright (C) 2016 Luxen - [[User:Luxen_Resident|Luxen_Resident]] - version 5.0
* Optimized: tested with more 90 users, low memory, safe and secure
</div></div>
</div></div>
<div id="box">


<div id="box">
==History==
==History==
<div style="padding: 0.5em 0.5em 1.5em">
<div style="padding: 0.5em;">
* Code based on my ''Zx Ultimate Radar'' created 3 years ago.
This version is optimized for the Language search.
* This version is optimized for the Language search.
* When a radar displays the nearest avatars, a language scanner need often to scan all the users so the script need to be a bit different than a radar...
* When a radar display the nearest users, a language scanner need often to scan all the users. If there are 90 users, it will scan them. So the script need to be a bit different than a radar...
</div></div>
</div></div>
<div id="box">
<div id="box">


== Code: ==
== Code: ==
</div>
<div style="padding: 0.5em;">
<source lang="lsl2">
<source lang="lsl2">
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                      Zx Language Scanner v5                              //
//                      Zx Language Scanner v5                              //
//                                                                          //
//                                                                          //
//   Copyright (C) 2016 Luxen - Zonyx Technology                           //
//                   By Luxen - Zonyx Technology                            //
//    This program is free software: you can redistribute it and/or modify  //
//    it under the terms of the GNU General Public License version 3, as    //
//    published by the Free Software Foundation.                           //
//                                                                          //
//    This program is distributed in the hope that it will be useful,      //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of        //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        //
//    GNU General Public License for more details.                          //
//                                                                          //
//  You should have received a copy of the GNU General Public License      //
//    along with this program.  If not, see <http://www.gnu.org/licenses/>  //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////


Line 240: Line 221:
}
}
</source>
</source>
</div></div>

Latest revision as of 16:45, 18 January 2017

User:Luxen_Resident | Teleporter_Anywhere | Ultimate_Radar | Language_Scanner | Visitor_Counter_Tracker

Summary

Advanced language scanner to detect users language, distance and names on a Sim.
You can easily filter by language with the menu. Useful to find who speak your language.

History

This version is optimized for the Language search.

  • When a radar displays the nearest avatars, a language scanner need often to scan all the users so the script need to be a bit different than a radar...

Code:

//////////////////////////////////////////////////////////////////////////////
//                      Zx Language Scanner v5                              //
//                                                                          //
//                   By Luxen - Zonyx Technology                            //
//////////////////////////////////////////////////////////////////////////////

integer counter = 0;
key owner = NULL_KEY;
list LangAffich = ["Default", "English", "Danish", "German", "Spanish", "French", "Italian", "Hungarian", "Dutch", "Polish", "Portuguese", "Russian"];
integer ZxMenu = 0;
integer Zchan = -4552155;
integer listenHandle;
string Av_Lang = "Default";
string SLang = "en";

set_time(float Stime, string Stext, integer Scounter)
{
        llSetText(Stext, <0.667, 0.667, 0.667>, 1.0);
        if (Stime != 5.0) llSetTimerEvent(Stime);
        counter = Scounter;
}

default
{
    state_entry()
    {
        if(owner)  ;
        else
        {
            owner = llGetOwner();
            set_time(10.0, "[- Starting -]", 0);
            Zchan = 0x80000000 | (integer)("0x"+(string)llGetKey());
        }
        ZxMenu = 0;
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if(change & (CHANGED_REGION)) state teleport;
    }
    
    touch_start(integer total_number)
    {   
        if (llGetAttached())
        {
            if (counter) 
            {
                if (!ZxMenu)
                {
                    key Touch = llDetectedKey(0);
                    if (Touch == owner)
                    {
                        llListenRemove(listenHandle);
                        ZxMenu = 1;
                        counter = 0;
                        listenHandle = llListen(Zchan, "", owner, "");
                        llDialog(owner, "by Luxen, Zonyx technology - Used Memory: " + llGetSubString((string)llGetUsedMemory(), 0, 1) + "k"
                             + "\n "
                             + "\n - Language: " + Av_Lang
                             + "\n (to reopen the menu: to wait some seconds)", LangAffich, Zchan);
                    }
                }
            }
        }
    }

    listen(integer channel, string name, key id, string msg)
    {
        if (ZxMenu)
        {
            if (llGetAttached())
            {
                if (channel == Zchan && id == owner)
                {
                    integer CheckTab = llListFindList(LangAffich, [msg]);
                    if (~CheckTab)
                    {
                        llListenRemove(listenHandle);
                        ZxMenu = 0;
                        Av_Lang = llList2String(LangAffich, CheckTab);
                        SLang = llList2String(["en", "en", "da", "de", "es", "fr", "it", "hu", "nl", "pl", "pt", "ru"], CheckTab);
                    }
                }
            }
        }
    }
    
    timer()
    {
        if (ZxMenu)
        {
            if (ZxMenu > 3)
            {
                llListenRemove(listenHandle);
                ZxMenu = 0;
                llOwnerSay("Resetting listen...\nMenu Off");
            }
            else ++ZxMenu;
        }
        
        list AvatarsDetect = llGetAgentList(AGENT_LIST_REGION, []);
        integer numOfAvatars = llGetListLength(AvatarsDetect);
        if (!llGetAttached())
        {
            if (llGetObjectPrimCount(llGetKey()))
            {
                set_time(0.0, "[- Off -]", 0);
            }
        }
        else if (numOfAvatars < 2)
        {
            if (counter != 2) set_time(5.0, "[- Nobody -]", 2);
        }
        else if (numOfAvatars > 100) return;
        else 
        {
            integer index;
            list NewTab = [];
            vector currentPos = llGetPos();
            integer Zfix = numOfAvatars;
            for (index = 0; index < Zfix; ++index)
            {
                key AvKey = llList2Key(AvatarsDetect, index);
                list AvPos = llGetObjectDetails(AvKey, [OBJECT_POS]);
                if (AvPos) NewTab += [llVecDist(currentPos, llList2Vector(AvPos, 0)), AvKey];
                else --numOfAvatars;
            }
            
            if (numOfAvatars > 1) 
            {
                AvatarsDetect = [];
                NewTab = llListSort(NewTab, 2, TRUE);
                string mode = "[- " + Av_Lang + " -]";
                numOfAvatars *= 2;
                if (llGetAgentLanguage(owner) != SLang) Zfix = FALSE;
                integer Av_Count = 0;
                for(index = 0; index < numOfAvatars; index += 2)
                {
                    key id = llList2Key(NewTab, index + 1);
                    string DLang = (string)llGetAgentLanguage(id);
                    if (DLang == "en-us") DLang = "en";
                    if (DLang == SLang) 
                    {
                        if (Zfix)
                        {
                            if (id == owner)
                            {
                                Zfix = FALSE;
                                jump Ignore;
                            }
                        }
                        string DName = llGetUsername(id);
                        if (DName) DName += " (" + DLang + "-" + (string)llList2Integer(NewTab, index) + "m)";
                        else DName = "???";
                        if (Av_Count > 9)
                        {
                            DName = mode + "\n" + DName;
                            if (llStringLength(DName) > 254) jump affich;
                            else mode = DName;
                        }
                        else mode += "\n" + DName;
                        ++Av_Count;
                    }
                    @Ignore;
                    
                }
                @affich;
                NewTab = [];
                if (!Av_Count) mode = "[- " + Av_Lang + ": 0 -]";
                set_time(5.0, mode, 1);
            }
        }
    }
}

state teleport
{
    state_entry()
    {
        if (counter) set_time(10.0, "[- Searching -]", 0);
        state default;
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }

    timer()
    {
        return;
    }
}