MantisBT - opensim
View Issue Details
0008459opensim[REGION] Script Functionspublic2019-01-19 12:462019-02-05 12:27
nixnerd 
 
normalminoralways
closedopen 
linuxlinuxmaster
 
 
OpenSim 0.9.1.0 Snail Dev 04f44bc 2019-01-18 03:02:39 +0000
Grid (1 Region per Sim)
BulletSim
Mono / Linux64
5.x
firestorm beta 64
0008459: visitor board script now wont render text correctly
visitor board script now wont render text correctly
//-------------------------------------------------------------------------------------------------------------
// 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 = [];

string gTime = "";

 list ListItemDelete(list mylist,string element_old) {
    integer placeinlist = llListFindList(mylist, [element_old]);
    if (placeinlist != -1)
        return llDeleteSubList(mylist, placeinlist, placeinlist);
    return mylist;
}

display()
{
    //string body = "width:256,height:256,aplha:FALSE,bgcolour:green";
    string body = "width:256,height:256,aplha:FALSE,bgcolour:black";
    string draw = "";
    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, 7);
    draw = osMovePen(draw, 10, 10);
    draw = osSetPenColor(draw, "white");
    draw = osDrawText(draw, log);

    osSetDynamicTextureDataBlendFace("", "vector", draw, body, FALSE, 2, 0, FALSE, 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 myShortenedList = ListItemDelete(avatarList, "");
        list myOtherShortenedList = ListItemDelete(myShortenedList, "");

        if ((string)myOtherShortenedList != (string)gDetected)
        {
            gTime = time();
            
            if (myOtherShortenedList != []) detectVisitorInOut(myOtherShortenedList);
            else visitorOut();
            
            gDetected = myOtherShortenedList;
            display();
        }
    }
}
No tags attached.
Issue History
2019-01-19 12:46nixnerdNew Issue
2019-01-19 13:10djphilNote Added: 0033860
2019-01-19 13:13djphilNote Edited: 0033860bug_revision_view_page.php?bugnote_id=33860#r7581
2019-01-19 13:24BillBlightNote Added: 0033861
2019-01-19 13:27djphilNote Edited: 0033860bug_revision_view_page.php?bugnote_id=33860#r7582
2019-01-19 13:29djphilNote Edited: 0033860bug_revision_view_page.php?bugnote_id=33860#r7583
2019-01-19 13:31nixnerdNote Added: 0033862
2019-01-19 13:32djphilNote Edited: 0033860bug_revision_view_page.php?bugnote_id=33860#r7584
2019-01-19 13:48nixnerdNote Added: 0033866
2019-01-19 13:54nixnerdNote Added: 0033867
2019-01-19 13:56BillBlightNote Added: 0033868
2019-01-19 13:57BillBlightNote Edited: 0033868bug_revision_view_page.php?bugnote_id=33868#r7588
2019-01-19 13:59djphilNote Added: 0033869
2019-01-19 14:02djphilNote Added: 0033870
2019-01-19 14:22nixnerdNote Added: 0033871
2019-01-19 14:27nixnerdNote Added: 0033872
2019-01-19 14:29nixnerdStatusnew => resolved
2019-02-05 12:27BillBlightNote Added: 0034311
2019-02-05 12:27BillBlightStatusresolved => closed

Notes
(0033860)
djphil   
2019-01-19 13:10   
(edited on: 2019-01-19 13:32)
Following the bug http://opensimulator.org/mantis/view.php?id=8442 [^] of recent change have been made on dynamic textures.

see http://opensimulator.org/viewgit/?a=commit&p=opensim&h=d8e5b7385ebe37bf27279f6afaf1acaa076eedee [^]
and http://opensimulator.org/viewgit/?a=commit&p=opensim&h=b2810c4ca718663f2bbc8c86646444d698873352 [^]

You can now fix your script by remplacing:
osSetDynamicTextureDataBlendFace("", "vector", draw, body, FALSE, 2, 0, FALSE, 4);

by this:
osSetDynamicTextureDataBlendFace("", "vector", draw, body, FALSE, 2, 0, 255, 4);

or by remplacing this:
string body = "width:256,height:256,alpha:FALSE,bgcolour:black";
osSetDynamicTextureDataBlendFace("", "vector", draw, body, FALSE, 2, 0, FALSE, 4);

by this:
string body = "width:256,height:256,alpha:255,bgcolour:black";
osSetDynamicTextureDataBlendFace("", "vector", draw, body, TRUE, 2, 0, FALSE, 4);

This depends on the desired end result ...

More exemples available on wiki @ http://opensimulator.org/wiki/OsSetDynamicTextureDataBlendFace [^]

(0033861)
BillBlight   
2019-01-19 13:24   
Isn't this a typo ..

aplha:FALSE
aplha:255


Should that not be
alpha
(0033862)
nixnerd   
2019-01-19 13:31   
Ah, thanks djphil and BillBlight, I missed that, will correct and re-test
(0033866)
nixnerd   
2019-01-19 13:48   
Adjusted script, as suggested, and currently it compiles, but fails to output any text text, successfully, script amended, as follows:

//-------------------------------------------------------------------------------------------------------------
// 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, FALSE, 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, FALSE, 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 = ["snik snoodle","pheonix renfold", "kemi mcalpine", "woody mcalpine", "higher skins", "Dummy Account"];
       
       list myCleanedList = ListXnotY(avatarList, myIgnoreList);
       
        if ((string)myCleanedList != (string)gDetected)
        {
            gTime = time();
            
            if (myCleanedList != []) detectVisitorInOut(myCleanedList);
            else visitorOut();
            
            gDetected = myCleanedList ;
            display();
        }
    }
}
(0033867)
nixnerd   
2019-01-19 13:54   
Ah strike that, I'm probly being an idiot, still testing :)
(0033868)
BillBlight   
2019-01-19 13:56   
(edited on: 2019-01-19 13:57)
I think you missed one in your display function

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

changed that to

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

and it works for me ..

(0033869)
djphil   
2019-01-19 13:59   
It produces the texture but only after 60 seconds ...

To remedy you can remplace:
state_entry() { llSetTimerEvent(60.0); }

by:
state_entry() { llSetTimerEvent(0.1); }

and add llSetTimerEvent(60.0); inside the timer function like this:

timer()
{
    llSetTimerEvent(60.0);
    ...
(0033870)
djphil   
2019-01-19 14:02   
I also advise you to replace:
width: 256, height: 256, ...
by
width: 512, height: 512, ...

and draw = osSetFontSize(draw, 5);
by draw = osSetFontSize(draw, 10);
or 14 etc ...
(0033871)
nixnerd   
2019-01-19 14:22   
you guys using the latest master of opensim?
(0033872)
nixnerd   
2019-01-19 14:27   
Issue resolved, thanks BillBlight and DJPhil :)
(0034311)
BillBlight   
2019-02-05 12:27   
Old Issues, closed, can be reopened if they still exist