Jump to content
Sign in to follow this  
Nia Mirabella

owner edit only on this script?

You are about to reply to a thread that has been inactive for 3213 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]);
    }
}

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3213 days.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...