Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting if no one is near

Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
02-11-2006 16:56
How can I do this:

Check for avatars every ...5 minutes
Detect if no one is near
If no one is near
//Do my stuff


~Thorne
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-11-2006 17:02
There is an example script that does this here.
Just change llSensor to something like llSensorRepeat("", NULL_KEY, AGENT, 10, PI, 300) and put it in state_entry instead of the touch_start event
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
02-11-2006 19:16
Works, cool thx!

I need it to not sensor if the texture of the prim is set to "red1". I tried the below but it does nothing. If I comment out the if statement, It just keeps detecting. With this script, if no one is near, the texture switches. But if the texture is already "red1", then it should do nothing.

Hmmm is that even possible? Since the script needs to be active to do anything at all? Confused...

CODE

default
{
state_entry()
{
string textureName1 = llGetInventoryName(INVENTORY_TEXTURE, currTexture1);
if (textureName1 != "red1")
llSensorRepeat("", NULL_KEY, AGENT, 3, PI, 10);

//do the work
Aliasi Stonebender
Return of Catbread
Join date: 30 Jan 2005
Posts: 1,858
02-11-2006 20:23
From: Thorne Kaiser
Works, cool thx!

I need it to not sensor if the texture of the prim is set to "red1". I tried the below but it does nothing. If I comment out the if statement, It just keeps detecting. With this script, if no one is near, the texture switches. But if the texture is already "red1", then it should do nothing.

Hmmm is that even possible? Since the script needs to be active to do anything at all? Confused...


llGetInventoryName does not do what you think it does. Use llGetTexture instead.

Also, once you start a sensor repeat, it keeps repeating; if you're wanting to be able to change the texture at any given time and have it stop, I'd do something like

CODE

sensor(integer num)
{
if (llGetTexture(0) == "red1")
llSensorRemove();
// other stuff goes here
}

no_sensor()
{
if (llGetTexture(0) == "red1")
llSensorRemove();
// other stuff goes here
}


roughly speaking.
_____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff