Jump to content

Script to action someting when no avatars detected


GloriaGlitter
 Share

You are about to reply to a thread that has been inactive for 1594 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I found a script in a forum post that came close to what I wanted which is to say something when one or more avatars are in range and to say something else when there are no avatars in range. The reason to say something when there are no avatars around to hear is that it is a command to listening poseballs to turn invisible.  The idea is to keep the land looking tidy when there are no avatars about.  The following script works ok except the timer keeps repeating the llSay when no avatars are around causing spam .  I know I need to remove the timer but when I do, the script doesn't work at all.  Here is the script I have:

integer SomebodyNear = 0;

default
{
state_entry()
{
llSetTimerEvent(10.0);
}

timer()
{
llSensor("",NULL_KEY,AGENT,5,PI);
}

sensor(integer num_detected)
{
if (SomebodyNear == 0)
  {
    llSay(0, "Click board to Show/Hide poseballs");
SomebodyNear = 1;
  }
}

no_sensor()
{
llSay(0, "hide");
SomebodyNear = 0;
}
}

 

Edited by GloriaGlitter
Link to comment
Share on other sites

That code... is doing things in a very round-about way.

Instead of calling a timer to repeatedly call a single sensor, consider using llSensorRepeat which will start a repeating sensor.

As for the message spam, you're communicating on channel 0... You could switch to using a different channel number and it won't be seen in local chat. Alternatively, consider using llRegionSayTo which sends the message directly to the target and no one else.

Edit: Another way to stop the spam entirely is to add an if condition to your no_sensor event. If somebodyNear equals 1, then say hide and set somebodyNear=0. Else do nothing. The idea is that if the poseballs are already hidden, it's redundant to re-send the hide command. Only bother doing it if they're currently visible.

Edited by Fenix Eldritch
Link to comment
Share on other sites

Thanks Fenix - actually the 'hide' message will go out on a channel number - I just had it on channel 0 while testing so I could see if it was working.  I suppose I meant lag instead of spam in that you are right, I wanted to avoid repeatedly sending the 'hide' message as it only needs to be said once and to reset when avatars again come within range.

Edit - implemented the changes you suggested and all works well.  Thanks :)

Edited by GloriaGlitter
Link to comment
Share on other sites

I suppose one message every 10 seconds isn't horrible, but yes I think it's preferable to not send the message at all when it isn't necessary - much like you already do in the sensor event. You only send the "click to show" message the first time you detect a nearby avatar. If SombodyNear equals 1, then you don't send the message. This avoids repeatedly sending the message when an avatar lingers within range of multiple sensor sweeps.

Link to comment
Share on other sites

All you really have to do is

no_sensor()
{
    if ( SomebodyNear == 1)
    {
        llSay(0, "hide");
        SomebodyNear = 0;
    }
}

That way, the script say "Hide" once, right after someone leaves, and that's it.

In the end, of course, this is one of those "If a tree falls in the forest ..." situations. If there is nobody there to see the poseballs, why do you care whether they are visible?

Edited by Rolig Loon
Link to comment
Share on other sites

7 minutes ago, Fenix Eldritch said:
12 minutes ago, Wulfie Reanimator said:

Is there an actual measurable difference or is this one of those "old traditions?"

No idea to be honest... it just irked me a bit :)

So I thought. You shouldn't be irked by something you don't even know to be meaningful.

Of all the things you could've been irked by, you chose the worst option.

Link to comment
Share on other sites

12 minutes ago, Wulfie Reanimator said:

Is there an actual measurable difference or is this one of those "old traditions?"

Probably no difference, but if you use llSensorRepeat, you aren't tying up a timer event, which you might need for something else.  It's not a bad habit to be in.

  • Like 1
Link to comment
Share on other sites

18 hours ago, GloriaGlitter said:

The idea is to keep the land looking tidy when there are no avatars about. 

23 minutes ago, GloriaGlitter said:

Regarding why I wanted the pose balls tidied up is so that the place doesn't look untidy for the next visitor :)

Apparently a visitor must get within 5m and until then the place stays "tidy" -- which also means the tiny poseball scripts aren't loaded in the sim unless they might be useful -- the price being that they'll get actively loaded when visitors appear, which is also when we might expect script load to cause the most trouble.

I admit to doing something similar: When a visitor collides with some scenery, I temp-rez some poseballs with very location-specific animations. If they don't interact with the poseballs for a minute or so, they vanish all on their own. They're not mesh so they don't count against the parcel Land Impact limits as long as I don't use any Materials properties (no alpha-masking nor emissive alpha, nor any specular- nor normalmaps).

Just in passing, though: If there's nobody even within draw distance, there's nobody to be bothered by untidiness. Also, if you happen to own the whole region, when nobody is in the region at all then there's nobody to benefit from fewer scripts. 

Link to comment
Share on other sites

1 hour ago, GloriaGlitter said:

Thanks guys, my script works perfectly now.  Regarding why I wanted the pose balls tidied up is so that the place doesn't look untidy for the next visitor :)

you are onto it

when we have more than a few pose balls, and a person is moving around on the parcel/region then all the pose balls beyond 5 meters of the person will not be visible, so less cluttered

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1594 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...