Jump to content

Disable/delete script upon being sat on by owner?


CamilleQ
 Share

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

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

Recommended Posts

I am trying to write a script that follows the owner until it is sat on by the owner then disables/deletes the script because it interferes with other scripts that are active that need to be operable once sat on or to make it non physical once sat on. help??

Link to comment
Share on other sites

You have many options, depending on whether you ever want to reuse the script again or not.  To remove the script, you want llRemoveInventory(llGetScriptName()).  If you just want to disable some function, to turn off an animation for example, just do a llStopAnimation or whatever it is in a changed event, activated by the sit.  You can also disable the entire script with llSetScriptState, which you can then reverse with a call from another script at a later time, if you wish.  It really all depends on what you want to do.

Link to comment
Share on other sites


Void Singer wrote:

changed( integer vBitChg ){    if (CHANGED_LINK & vBitChg){        if (llGetOwner() == llGetLinkKey( ~-llGetNumberOfPrims( ) )){            //-- disable the script in some way        }    }}

 

Could you explain ~-llGetNumberOfPrims(), please, Void?  

And why would I use it in preference to if( llGetOwner()==llAvatarOnSitTarget() )?  Assuming I know  I've set a sit target, that is?

On a related topic, now I come to think of it, is there a clever way to check if, when someone gets off the object, the owner is still among the seated avatars?      Often I need to know, when someone gets off my BDSM furniture, if it's the victim or someone else, and I've never really been sure which of the various methods I've thought up is the best one.

Link to comment
Share on other sites

That's a good question.  I can see wanting to use llGetLinkKey(llGetLinkNumber) instead of llAvatarOnSitTarget , because it works even if you haven't set a sit target.  However, ~-n = (n-1), so writing llGetLinkKey(~- llGetLinkNumber) looks like it would get you the key of the next to last link in the linkset, which is not the key of whoever just sat on it.

Try putting this in a single prim and sitting on it.

default{    touch_start(integer total_number)    {        llSay(0, (string)llGetLinkKey( llGetNumberOfPrims()) + " " + (string)llGetLinkKey( ~-llGetNumberOfPrims()));    }}

 The first key you get is your own key (you are prim #2) and the second is the key of the prim iself (prim #1). So, I'm with you Innula.  Why would you want to do this?  Void?? 

 

Link to comment
Share on other sites

because I was tired and forgot that multiprim objects index from 1 and not 0 =X

as for why that instead of llAvatarOnSitTarget.... for just the reason stated... it may not be the sit target that the owner sits on, or it may be one on a different prim (the whole set gets the changed event though)

 

for detecting when a particular av gets up, aside from testing llAvatarOnSitTarget in the specific prim, the only way to know for sure is to loop through an test all the links above the actual prims in the set (which you can get from llGetObjectPrimCount), although there's a small shortcut in that if you text the last link, and it hasn't changed, then a previously seated av got up, or the last got up if it did change (assuming the llNumberOfPrims went down)

obviously sit target is easier, but requires a script in that prim, which can be troublesome

Link to comment
Share on other sites

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