Hide pictures while offline - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Hide pictures while offline


Scripting Discuss scripting for SL and other platforms

Reply
 
LinkBack Thread Tools Display Modes
Old 11-06-2009, 05:42 PM   #1 (permalink)
Mr. Mannonen
 
Beowulf Blackburn's Avatar
in love... ALWAYS!!!
 
Join Date: Jul 2009
Location: in the eyes of my soulmate...
Posts: 31
SL Join Date: 11/13/2007
Business: none
Hide pictures while offline

Ok I do not know if it is possible but I am looking for a script that only show the pictures on my walls when me and my partner are online, so when one of us is online they are shown, if we both are offline they should be replaced by let say a solid black texture... is this possible? I have seen temp rezzers that only work when the owner is online and maybe it works whit textures too?
Beowulf Blackburn is offline   Reply With Quote
Old 11-06-2009, 06:40 PM   #2 (permalink)
Emergency Mustelid
 
Argent Stonecutter's Avatar
 
Join Date: Sep 2009
Posts: 1,073
Avatar On/Offline Detection

Not the whole script of course, but make a box and have it call llSetTexture() on face zero when you're detected. Or maybe llSetColor() the texture black when you're not.
Argent Stonecutter is offline   Reply With Quote
Old 11-06-2009, 06:58 PM   #3 (permalink)
Mr. Mannonen
 
Beowulf Blackburn's Avatar
in love... ALWAYS!!!
 
Join Date: Jul 2009
Location: in the eyes of my soulmate...
Posts: 31
SL Join Date: 11/13/2007
Business: none
thanks but that would only work for me as the owner right? what if i wanted to have my parnter in there too so that it detects two avatars woudl that be possible too?

Sorry I am a scripting impaired guy ;-)
Beowulf Blackburn is offline   Reply With Quote
Old 11-06-2009, 06:59 PM   #4 (permalink)
aircraft manufacturer
 
Cubey Terra's Avatar
in the clouds
 
Join Date: Aug 2007
Location: Vancouver, BC
Posts: 582
SLShopper Ads: 12
SL Join Date: September 2003
Business: Abbotts Aerodrome
Send a message via Skype™ to Cubey Terra
Post

Instead of using an online detector, maybe you instead want to see if the right people are present in the house? That way pictures are blacked out if you're online, but elsewhere.

Here's my attempt. [Edit: I tested it... works ok.]

Code:
// PICTURE BLACKOUT

// LOOKS FOR PEOPLE ON A LIST
// IF NOBODY ON THE LIST IS PRESENT, IT TURNS THE PRIM BLACK

// Instructions: 
// 1. Put this script in the same prim that has the picture on it.
//
// 2. In that prim's Description field, list all the people who the picture should show itself to. Separate names with a comma, no spaces.
// example:
// Cubey Terra,Beowulf Blackburn,Philip Linden,Cristiano Midnight,Aimee Weebler


float INTERVAL = 60; // how often in seconds to check for people on whitelist
float RANGE = 90; // range of sensor
vector CLR_ON = <1,1,1>;
vector CLR_OFF = <0,0,0>;

integer isOnList(string name)
{
    list people = llCSV2List(llGetObjectDesc());
    integer num = llGetListLength(people);
    integer i;
    for (i=0;i<num;i++)
    {
        if (llToLower(name) == llToLower(llList2String(people,i))) // compare names in lower case because SL names are often mistyped
        {
            return TRUE;
        }
    }
    return FALSE;
}


default
{
    
    state_entry()
    {
        llSetTimerEvent(INTERVAL);
    }
    
    timer()
    {
        llSensor("","",AGENT,RANGE,TWO_PI); // Scans for all agent in RANGE
    }
    
    sensor(integer num_detected)
    {
        integer i;
        integer detected;
        for (i=0;i<num_detected;i++)
        {
            string name = llDetectedName(i); 
            if (isOnList(name)) // if a detected agent is on the list...
            {
                detected = TRUE;
            }
        }
        if (detected) 
        {
            if (llGetColor(0) != CLR_ON) llSetColor(CLR_ON,ALL_SIDES);
        }
        else
        {
            if (llGetColor(0) != CLR_OFF) llSetColor(CLR_OFF,ALL_SIDES);
        }
    }
}

Last edited by Cubey Terra; 11-06-2009 at 07:08 PM.
Cubey Terra is offline   Reply With Quote
Old 11-06-2009, 07:02 PM   #5 (permalink)
Emergency Mustelid
 
Argent Stonecutter's Avatar
 
Join Date: Sep 2009
Posts: 1,073
That's good, that works too.
Argent Stonecutter is offline   Reply With Quote
Old 11-06-2009, 07:16 PM   #6 (permalink)
Mr. Mannonen
 
Beowulf Blackburn's Avatar
in love... ALWAYS!!!
 
Join Date: Jul 2009
Location: in the eyes of my soulmate...
Posts: 31
SL Join Date: 11/13/2007
Business: none
Thanks so much for the help!!! It works perfect!!!
Beowulf Blackburn is offline   Reply With Quote
Old 11-06-2009, 09:33 PM   #7 (permalink)
exp(ln(Gearhead))
 
Aodhan McDunnough's Avatar
 
Join Date: Jun 2007
Location: Philippines
Posts: 5,842
My Mood:
SLShopper Ads: 2
SL Join Date: March 28, 2006
Business: Aodhan's Forge
Blog Entries: 2
Sensors are heavy loads on sims when a lot of people are in range, so it's best to reduce the frequency and range to what is necessary. The 60 sec interval is good.

float RANGE = 90; // range of sensor

Change the 90 to whatever range from which you still wish to be able to view the pic.
Aodhan McDunnough is online now   Reply With Quote
1 User Agreed:
Old 11-08-2009, 06:34 PM   #8 (permalink)
The Purple
 
Chalice Yao's Avatar
Kinda at work. Somewhat.
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 3,096
My Mood:
I'd not use sensors for this..after all, you can be online without being in sensor range. :3

Code:
list AVATARS=["Youravatarkey","anotheravatarkey","yetanotheravatarkey"];

list lImageLinks;
integer iPrimAmount;
integer iAvatarListLength;
integer iTemp;
integer iTemp2;
integer iTemp3;
key kQuery;
string sTemp;

getPrims()
{
    llSetTimerEvent(0);
    kQuery=NULL_KEY;
    iTemp=iPrimAmount=llGetNumberOfPrims();
    lImageLinks=[];
    do
    {
        if(llListFindList(AVATARS,[sTemp=llGetLinkName(iTemp)]) != -1)
        {
            lImageLinks+=sTemp;
            lImageLinks+=iTemp;
            lImageLinks+=0;
            llSetLinkColor(iTemp,<0,0,0>,2);
        }
    }
    while(iTemp=~-iTemp);
    llSetTimerEvent(60);
}

default
{
    state_entry()
    {
        iAvatarListLength=AVATARS != [];
        getPrims();
                //if(lImageLinks != [])
                    llSetTimerEvent(0.01);
    }
    changed(integer change)
    {
        if(change & CHANGED_LINK)
            getPrims();
    }
    timer()
    {
        llSetTimerEvent(0);
        iTemp2=llListFindList(lImageLinks,[sTemp=llList2String(AVATARS,iTemp=0)]);
        kQuery=llRequestAgentData((key)sTemp,DATA_ONLINE);
    }
    dataserver(key query, string data)
    {
        if(kQuery==query)
        {
            if((integer)data)
            {
                if(!(llList2Integer(lImageLinks,iTemp3=iTemp2+2)))
                {
                    llSetLinkColor(llList2Integer(lImageLinks,iTemp2+1),<1,1,1>,2);
                    llListReplaceList(lImageLinks,[1],iTemp3,iTemp3);
                }
            }
            else
            {
                if(llList2Integer(lImageLinks,iTemp3=iTemp2+2))
                {
                    llSetLinkColor(llList2Integer(lImageLinks,iTemp2+1),<0,0,0>,2);
                    llListReplaceList(lImageLinks,[0],iTemp3,iTemp3);
                }
            }
            if((iTemp=-~iTemp) < iAvatarListLength)
            {
                iTemp2=llListFindList(lImageLinks,[sTemp=llList2String(AVATARS,iTemp)]);
                kQuery=llRequestAgentData(sTemp,DATA_ONLINE);
            }
            else
            {
                iTemp=iTemp2=0;
                kQuery=NULL_KEY;
                llSetTimerEvent(60);
            }
        }
    }
}
How this works:

1. Have a single, linked object.
2. Give the prims that are supposed to show the pictures the UUIDs/Keys of the avatars as names.
3. Put the pictures on the front of the prims. For example on a cube, put the texture on the face on the positive X axis
4. Put the avatar keys at the top of this script
5. Slip the script into the root prim.
6. Voila. It will now show the images if the avatars are online, or turn them black if they are offline, no matter if they are in the same sim or across the grid. No sensors involved. It checks every 60 seconds.

You only need this single script in the whole build. You can unlink and relink the whole object anytime. If you want to add people, just give another prim the new avatar key, add the key to the list at the top of the script, and save it.
__________________
"Have you ever noticed that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?" - George Carlin

Last edited by Chalice Yao; 11-10-2009 at 08:28 PM.
Chalice Yao is offline   Reply With Quote
Old 11-08-2009, 08:52 PM   #9 (permalink)
Emergency Mustelid
 
Argent Stonecutter's Avatar
 
Join Date: Sep 2009
Posts: 1,073
Cubey's point is that for this application, being in sensor range is probably more useful.

I agree.
Argent Stonecutter is offline   Reply With Quote
Old 11-09-2009, 04:59 AM   #10 (permalink)
The Purple
 
Chalice Yao's Avatar
Kinda at work. Somewhat.
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 3,096
My Mood:
Quote:
Originally Posted by Argent Stonecutter View Post
Cubey's point is that for this application, being in sensor range is probably more useful.

I agree.
Dunno Argent, most online-walls for employees that I've found actually also show online status when the employees are off-sim, in case they are pretty much on-duty for IM-based support.

Actually, what the thing is missing is a way to set oneself on/offduty via click. I guess that'd make more sense than anything, and would require the item to only check if somebody clicked it, is 'on duty' but then went offline, and turns off their image. It shoudn't actually check if people come online, only enable the image after a click on it by the person. After all, not everybody wants to instantly get shown as available after login, nor when they merely hang at the place.

I'll write that up later.

*Pokes Beowulf* Up to your preferences of course.

Last edited by Chalice Yao; 11-09-2009 at 05:05 AM.
Chalice Yao is offline   Reply With Quote
Old 11-09-2009, 06:12 AM   #11 (permalink)
Emergency Mustelid
 
Argent Stonecutter's Avatar
 
Join Date: Sep 2009
Posts: 1,073
Oh, I thought this was for a home application. I guess I always thought those "tell me when the store owner is online" scripty things were kind of silly, so that application never occurred to me.
Argent Stonecutter is offline   Reply With Quote
Old 11-09-2009, 07:18 AM   #12 (permalink)
The Purple
 
Chalice Yao's Avatar
Kinda at work. Somewhat.
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 3,096
My Mood:
Quote:
Originally Posted by Argent Stonecutter View Post
Oh, I thought this was for a home application. I guess I always thought those "tell me when the store owner is online" scripty things were kind of silly, so that application never occurred to me.
Oh, they are handy if the store has employees. I've done customer support for TOC for a while, and the board was quite frequently used by the customers.
Chalice Yao is offline   Reply With Quote
Old 11-09-2009, 02:45 PM   #13 (permalink)
Junior Member
 
abVanmoer's Avatar
 
Join Date: Oct 2009
Posts: 19
Business: ab's Emporium
Quote:
Originally Posted by Beowulf Blackburn View Post
I have seen temp rezzers that only work when the owner is online and maybe it works whit textures too?
A slight digression - a lot of the time it isn't intended for the temp rezzers to only work when the owner is online, often the owner doesn't even realise it and wonder's why their holo rez vendors or teleport devices sometimes don't work.

Many people don't realise for these devices to work while the owner is offline, the owner of the object needs to have offline building rights on the land. This is automatic if the owner also owns the land, or if the land is owned by a group and the object is deeded to the group. Alternatively if it is group owned land, and group members are allowed to build, and the owner of the object is a member of the group, the object needs to be set to the group.
__________________
Vendors, clocks, timers, neon signs, donation boxes and other gadgets
Xstreet: https://www.xstreetsl.com/modules.ph...rchantID=45738
In-world: http://slurl.com/secondlife/Monowai/237/111/68
Web: http://www.absemporium.com
abVanmoer is offline   Reply With Quote
Old 11-10-2009, 08:28 PM   #14 (permalink)
The Purple
 
Chalice Yao's Avatar
Kinda at work. Somewhat.
 
Join Date: Dec 2007
Location: Somewhere purple, Germany
Posts: 3,096
My Mood:
Updated the code. Had a small, silly logic bug in it.
Chalice Yao is offline   Reply With Quote
Old 11-17-2009, 06:29 PM   #15 (permalink)
Mr. Mannonen
 
Beowulf Blackburn's Avatar
in love... ALWAYS!!!
 
Join Date: Jul 2009
Location: in the eyes of my soulmate...
Posts: 31
SL Join Date: 11/13/2007
Business: none
I just found the replies, yes I am old and yes I can be ridicously slow at times, thanks for the Code Chalice, I was going for a pure home use for this. As I have some pictures that are more pricate and should not be shown to random avatars that happen to come into our house when we are not there ;-)

I will try out your code too, but couldn't really inspect any additional lag in my home so far with Cubeys Code....
Beowulf Blackburn is offline   Reply With Quote
Old 11-17-2009, 06:40 PM   #16 (permalink)
Emergency Mustelid
 
Argent Stonecutter's Avatar
 
Join Date: Sep 2009
Posts: 1,073
That's the kind of thing I thought you were looking for. You'd be better off with Cubey's code, then, since you probably don't want the pictures shown when you're online but off in a club somewhere else.
Argent Stonecutter is offline   Reply With Quote
Old 11-17-2009, 07:46 PM   #17 (permalink)
aircraft manufacturer
 
Cubey Terra's Avatar
in the clouds
 
Join Date: Aug 2007
Location: Vancouver, BC
Posts: 582
SLShopper Ads: 12
SL Join Date: September 2003
Business: Abbotts Aerodrome
Send a message via Skype™ to Cubey Terra
Post

It's true, sensors cause lag. If you have a lot of pictures, may I suggest this much shorter script?

This one uses llKey2Name to discover if the picture's owner is in the sim (or has been in the sim recently). If not, llKey2Name returns a null string, otherwise, it returns the owner's name.

Very simple, very short, no sensors.

Code:
// PICTURE BLACKOUT BY OWNER
// CHECKS IF PRIM'S OWNER IS PRESENT IN THE SIM. IF NOT, IT TURNS THE PRIM BLACK

// Instructions:  Put this script in the same prim that has the picture on it.

float INTERVAL = 15; // how often in seconds to check if owner is present in the sim
vector CLR_ON = <1,1,1>;
vector CLR_OFF = <0,0,0>;

default
{
    state_entry()
    {
        llSetTimerEvent(INTERVAL);
    }
    
    timer()
    {
        if (llKey2Name(llGetOwner()) == "") llSetColor(CLR_OFF,ALL_SIDES);
        else llSetColor(CLR_ON,ALL_SIDES);
    }
}
Cubey Terra is offline   Reply With Quote
1 User Said Thanks:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On