MantisBT - opensim
View Issue Details
0008907opensim[REGION] Scripting Enginepublic2021-07-05 12:032021-07-05 15:44
nixnerd 
 
normalminoralways
resolvedopen 
LinuxLinuxLinux
 
 
master
Standalone (1 Region)
ubODE
XEngine
Mono / Linux64
6.x
Firestorm 6.4.13 (63251)
0008907: visitor script no longer appears to work
visitor script no longer appears to work
//-------------------------------------------------------------------------------------------------------------
// Artemis Tesla 2010-12-12
//Script for showing visitors log on a board
//Put script on a prim and reset
//Requires osGetAgents to be enabled in Opensim\bin\config-include\osslEnable.ini :
//Allow_osGetAgents = ${XEngine|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER
//or put line in opensim.ini [xengine] section if not using osslEnable.ini file
//Jeff Hall - September 2017
//-------------------------------------------------------------------------------------------------------------

list gDetected = [];
list gVisitors = [];
list myIgnoreList = [];
list myCleanedList = [];

string gTime = "";
string FontName = "Arial";

list ListXnotY(list lx, list ly) {// return elements in X list that are not in Y list
    list lz;
    integer i = llGetListLength(lx);
    while(i--)
    if ( !~llListFindList(ly,llList2List(lx,i,i)) ) // * see Note
            lz += llList2List(lx,i,i);
    return lz;
}

display()
{
    string body = "width:256,height:256,aplha:FALSE,bgcolour:green";
    string draw = "";
   // string body = "width:256,height:256,alpha:255,bgcolour:black";
    osSetDynamicTextureDataBlendFace("", "vector", draw, body, TRUE, 2, 0, 255, 4);
       string log = "Visitors";
    
    integer visitors = llGetListLength(gVisitors) / 3;
    
    while(visitors--)
    {
        log = log + "\n" + llList2String(gVisitors, visitors * 3 + 2) + " - " +
                           llList2String(gVisitors, visitors * 3 + 1) + " - " +
                           llList2String(gVisitors, visitors * 3);
    }

    draw = osSetFontSize(draw, 5);
    draw = osSetFontName(draw, FontName);
    draw = osMovePen(draw, 10, 10);
    draw = osSetPenColor(draw, "white");
    draw = osDrawText(draw, log);

   osSetDynamicTextureDataBlendFace("", "vector", draw, body, TRUE, 2, 0, 255, 4);


}

string time()
{ //0123 4 56 7 89 0 12 3 45
    //YYYY - MM - DD T hh : mm:ss.ff..fZ
    string now = llGetTimestamp();
    return llGetSubString(now,0,9) + " " +
           llGetSubString(now,11,15);
}

string duration(string timeIn, string timeOut)
{
    integer came = ((integer)llGetSubString(timeIn,11,12) * 60) + (integer)llGetSubString(timeIn,14,15);
    integer went = ((integer)llGetSubString(timeOut,11,12) * 60) + (integer)llGetSubString(timeOut,14,15);
    
    if (came == went) if(llGetSubString(timeIn,8,9) != llGetSubString(timeOut,8,9)) went = went + 1440;
    
    if (came > went) went = went + 1440;
    went = went - came;
    
    return llGetSubString("00" + (string)((went - (went % 60)) / 60), -2, -1) + ":" +
           llGetSubString("00" + (string)(went % 60), -2, -1);
}

detectVisitorInOut(list avatars)
{
    integer avatar = llGetListLength(avatars);
    string name = "";
    
    while(avatar--)
    {
        name = llList2String(avatars, avatar);
        if (llSubStringIndex((string)gDetected, name) == -1) gVisitors = gVisitors + [name, "00:00", gTime];
        
        if (llGetListLength(gVisitors) >= 63) gVisitors = llDeleteSubList(gVisitors, 0, 2);
    }
    
    avatar = llGetListLength(gDetected);
    name = "";

    while(avatar--)
    {
        name = llList2String(gDetected, avatar);
        if (llSubStringIndex((string)avatars, name) == -1)
        {
            integer position = llListFindList(gVisitors, [name, "00:00"]) + 1;
            string time = duration(llList2String(gVisitors, position + 1), gTime);
            gVisitors = llListReplaceList(gVisitors, [time], position, position);
        }
    }
}

visitorOut()
{
    integer avatar = llGetListLength(gDetected);
    string name = "";
    
    while(avatar--)
    {
        name = llList2String(gDetected, avatar);
        integer position = llListFindList(gVisitors, [name, "00:00"]) + 1;
        string time = duration(llList2String(gVisitors, position + 1), gTime);
        gVisitors = llListReplaceList(gVisitors, [time], position, position);
    }
}

default
{
    state_entry() { llSetTimerEvent(60.0); }
    
    timer()
    {
                   
       list avatarList = osGetAgents();

       list myIgnoreList = [""];
       
       list myCleanedList = ListXnotY(avatarList, myIgnoreList);
       
        if ((string)myCleanedList != (string)gDetected)
        {
            gTime = time();
            
            if (myCleanedList != []) detectVisitorInOut(myCleanedList);
            else visitorOut();
            
            gDetected = myCleanedList ;
            display();
        }
    }
}
No tags attached.
Issue History
2021-07-05 12:03nixnerdNew Issue
2021-07-05 12:07tampaNote Added: 0037842
2021-07-05 12:12djphilNote Added: 0037843
2021-07-05 12:46danbannerNote Added: 0037844
2021-07-05 13:07kcozensNote Added: 0037845
2021-07-05 15:15nixnerdNote Added: 0037846
2021-07-05 15:25kcozensNote Added: 0037847
2021-07-05 15:42nixnerdNote Added: 0037848
2021-07-05 15:44nixnerdStatusnew => resolved

Notes
(0037842)
tampa   
2021-07-05 12:07   
Expected behavior?
Observed behavior?
Need a bit more info than just "it don't work" ;P
(0037843)
djphil   
2021-07-05 12:12   
Work for me :p
(0037844)
danbanner   
2021-07-05 12:46   
Works for me too on latest dev
(0037845)
kcozens   
2021-07-05 13:07   
The only thing I notice that is questionable is the use of ~ in ListXnotY() when checking the return value from llListFindList. If the list isn't found the return from the function is -1. I think you should be checking for that value being returned. The comment on the line says to "See note" but I don't see any note in what was pasted.
(0037846)
nixnerd   
2021-07-05 15:15   
It doesn't work, in so much as it doesn't appear to update the texture of the prim the scripts in, tp'ing out to another sim and back, the texture still doesn't show any visitors
(0037847)
kcozens   
2021-07-05 15:25   
Is the object with the script in it owned by the estate manager or estate owner?
(0037848)
nixnerd   
2021-07-05 15:42   
My mistake its working fine :)