Change font size
It is currently Wed Dec 19, 2018 12:49 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: LogVisitors
PostPosted: Sat Jul 07, 2012 2:50 am 

Joined: Tue Nov 16, 2010 7:45 am
Posts: 9
Gets avatars in sim and records when they come and go keeps the last twenty one or so visitors

{L_CODE}:
// Artemis Tesla 2010-12-12

list gDetected = [];
list gVisitors = [];

string gTime = "";

display()
{
    string body = "width:256,height:256,aplha:FALSE,bgcolour:green";
    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();

        if ((string)avatarList != (string)gDetected)
        {
            gTime = time();
           
            if (avatarList != []) detectVisitorInOut(avatarList);
            else visitorOut();
           
            gDetected = avatarList;
            display();
        }
    }
}


Top
 Profile  
 
 Post subject: Re: LogVisitors
PostPosted: Sun Jul 08, 2012 5:30 am 
User avatar

Joined: Tue Jun 12, 2012 1:23 am
Posts: 26
Location: Germany
Hi Artemis,

I'm totally new to this so it might be no wonder, I don't get it to work. I put it into a rezzed cube, gave script and prim a nice name and it said "running". Now it sits there and looks like a regular cube. What is it supposed to do? I teleported around a bit but nothing changes. Does myself count as a visitor too?

Thanks

Phaa

_________________
The world is coming to an end - SAVE YOUR BUFFERS!


Top
 Profile  
 
 Post subject: Re: LogVisitors
PostPosted: Sun Jul 08, 2012 6:00 am 

Joined: Sun Jul 08, 2012 4:46 am
Posts: 1
Nice script thankyou :) I like this better than the one I have, no floating text.

@Phandoor it is supposed to paint a texture on the side with writing of a log of visitors. If it's not working make sure you have opensim scripting commands enabled for you on your region. I think the verylow threat level should work, as that's what mine is set at.

this might help : http://opensimulator.org/wiki/OSSL_Enabling_Functions


Top
 Profile  
 
 Post subject: Re: LogVisitors
PostPosted: Sun Jul 08, 2012 7:55 am 
User avatar

Joined: Tue Jun 12, 2012 1:23 am
Posts: 26
Location: Germany
Oh yes, thanks Harriette. It was on the back side of the cube :oops:

_________________
The world is coming to an end - SAVE YOUR BUFFERS!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net