Jump to content

owner edit only on this script?


Nia Mirabella
 Share

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

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

Recommended Posts

One of the regulars here was nice enough to cook up this script for me but unfortunately only 'I' can turn the light in the prim on and off. Can someone please show me or add on to this script where I would put owner activate instead of creator activate, or whatever the term is? Thank you!

 

default
{
    state_entry()
    {
        llListen(0,"",llGetOwner(),"");
    }
    listen(integer chan, string name, key id, string mes)
    {
        if (mes=="on")
            llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.2]);
        else if (mes=="off")
            llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0]);
    }
}

Link to comment
Share on other sites

The problem is that the script is listening to whoever was its owner at the time it started running.   It doesn't realise that the owner has changed unless you tell it to check, something like this:

 

integer handle;default{	state_entry()	{		handle = llListen(0,"",llGetOwner(),"");	}	changed(integer change)	{		if(change & CHANGED_OWNER){			llListenRemove(handle);			handle = llListen(0,"",llGetOwner(),"");		}	}	listen(integer chan, string name, key id, string mes)	{		if (mes=="on"){			llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.2]);		}		else if (mes=="off"){			llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0]);		}	}}

 The changed event can detect various types of change, including a change of owner.   So what the script now says is something like "if the owner changes, stop listening to the old one and start listening to the new one".

Is it really necessary to have it listen on the open chat channel?  Open listeners on 0 really do contribute to lag and, to my mind,  should be avoided unless there's a very good reason to be listening on the chat channel. 

Link to comment
Share on other sites

  • 2 weeks later...

Depends on the script, I guess.  In general, though, I try to avoid using llResetScript() unless I do, in fact, want to reset everything, because, more often than not, it means I'm telling the script to reset of things that don't need resetting, which is inefficient, and, quite possibly, I'm wiping out the values of variables I would want to keep.

In this example it doesn't make much difference, I agree, but I try to stop myself from using llResetScript too readily.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4578 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...