Skip to content

Z ‐ [Legacy] LSL scripts

Madpeter edited this page Jun 25, 2024 · 1 revision

Hello world

key botUUID = "";
string secret = "";

parseCmd(string cmd,list args,string replytarget)
{
    string raw = cmd+llDumpList2String(args, "~#~");
    string cooked = llSHA1String(raw+secret);
    string built = cmd+"|||"+llDumpList2String(args, "~#~")+"#|#"+replytarget+"@@@"+cooked;
    llInstantMessage(botUUID, built);
}

default
{
    touch_end(integer a)
    {
        parseCmd("Say",[0,"hi there: "+llDetectedName(0)],"");
    }
}

Doorbell (Collison triggered im+sound)

key botUUID = "";
string secret = "";

parseCmd(string cmd,list args,string replytarget)
{
    string raw = cmd+llDumpList2String(args, "~#~");
    string cooked = llSHA1String(raw+secret);
    string built = cmd+"|||"+llDumpList2String(args, "~#~")+"#|#"+replytarget+"@@@"+cooked;
    llInstantMessage(botUUID, built);
}

list last_10_seen = [];

default
{
    state_entry()
    {
        llVolumeDetect(TRUE);
    }
    collision_start(integer a)
    {
        integer loop = 0;
        while(loop < a)
        {
            if(llListFindList(last_10_seen,[llDetectedKey(loop)]) == -1)
            {
                last_10_seen += [llDetectedKey(loop)];
                if(llGetListLength(last_10_seen) > 10)
                {
                    last_10_seen = llListReplaceList(last_10_seen,[],0,0);
                }
                llPlaySound("fe8b847e-4dea-ce0c-eaef-f73fd9e168b2",1.0);
                list message_bits = [
                    "Hello and welcome to location",
                    llDetectedName(loop),
                    ". bla bla bla bla bla"
                    ];
                parseCmd("IM",[(string)llDetectedKey(loop),llDumpList2String(message_bits,"")],"none");
            }
            loop++;
        }
    }
}