Jump to content

How to read the wearers ID into global?


Assmay
 Share

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

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

Recommended Posts

Hi,

today I tried a lot to get a lockguard script working.

It is easy to get it working with touch_start but I need it working with on_rez because I want the chains still visable after the wearer of the anklets relogs.

default
{

   on_rez(integer start_param)
   {

      llWhisper( -9119, "lockguard " + (string)llDetectedKey(0) + " wrists link " + (string)llGetKey() );

   }

}

 This isnt working because GetKey doesnt work with on_rez.

So I have to find a way to read the key of the wearer of this attachment (whoever wears it) during a touch_start event.

Does anybody knows how I can save the wearers ID to a global value like "key wearer;"?

Link to comment
Share on other sites

I'm not quite clear about the sequence of events you have in mind. If your object is supposed to be worn, though, the only person who can wear it will be its owner.  Therefore, you know that key already.  It's  llGetOwner().  The object's own UUID is provided by llGetKey(), which will work exactly the way you have it written.

Link to comment
Share on other sites

Where are you trying to put that?  You can't calculate a variable's value outside of an event.  If you want to use owner as a global variable for some reason, declare it at the top of your script and then assign it the value llGetOwner() in an event in your script.

Link to comment
Share on other sites

I cant use it like it is because I have to use on_rez as event. Gathering the ID only works with touch / touch_start as far as I heard.

 

My problem is to retoggle the script after a relog and it wont work with on_rez. If the UUID is packed as a gloval value it should work I hope.

Link to comment
Share on other sites

I'm sorry, but I really don't understand what you want to do.  There's no toggle in that script.  And I don't truly understand why you need to create a global variable for anything.  Or why you need to "gather" an ID.  As I pointed out before, you already know the UUID of the person wearing your object.  That person is the object's owner, and his UUID is llGetOwner().  That won't change unless he gives the object to someone else.

Do you want this object to whisper information whenever it is attached?  If so, write

default{   on_rez(integer start_param)   {        if(llGetAttached() == 0) // That is, if this object was rezzed but not worn        {            llOwnerSay("Please wear this object.");        }    }        attach (key id)    {        if (id) // That is, if attached        {            llWhisper( -9119, "lockguard " + (string)llGetOwner() + " wrists link " + (string)llGetKey() );        }    }}

 

Link to comment
Share on other sites

*smiles*... yes I know it is hard to imagine what I try to program (I´m not sure myself yet ;) )

 

The only problem is that I have to use llDetectedKey with an event which starts automatically like on_rez or timer.

If I try to detect the key of the owner of the attachment (in my tests me) it only comes 00000-0000-0000000-0000 back.

 

So I need to get the key of the attachment owner with on_rez or timer or something I dont have to touch or so.

 

Is it possible to read the key by a touch event once and after this it is resistant as a "key" or "string" in the script until it gets resetted or so?

Link to comment
Share on other sites

We're still not communicating well here. :smileyfrustrated: There is no reason why you need to touch the object to get the owner's UUID.  You don't need llDetectedKey()You already know what the UUID is, by definition.  An attachment can only be worn by its owner.  Therefore, the UUID of the person who wears the object is llGetOwner().  If you write the attach event the way I did in my last post, the Whisper message will say the wearer's UUID automatically, without you touching a thing.

I assume that the Whisper message is being heard by another script that is your "locking" routine.  I'm sure that it can remember the UUID when you pass it, and there shouldn't be any need to tell it again.  Actually, you don't even need to pass it the UUID, since it knows who's wearing the object too.  It's easy enough to have that script see who llGetOwner is, all by itself.  The only information you need to pass from the worn object is the key of the worn object, and that is also already being passed and can be read in the receiving script's listen event.  :smileywink:

 These two scripts should be all that you need.  In the worn object:

default{   on_rez(integer start_param)   {        if(llGetAttached() == 0) // That is, if this object was rezzed but not worn        {            llOwnerSay("Please wear this object.");        }    }        attach (key id)    {        if (id) // That is, if attached        {            llWhisper( -9119, "Hello!" ); //Or any other message        }    }}

 In the "locking" script:

default{    state_entry()    {        llListen(-9119,"","","");    }    listen(integer channel, string name, key id, string msg)    {        if (llGetOwnerKey(id) == llGetOwner() )        {            // LOCK THE ATTACHMENT WITH UUID = id        }    }}

 

 

 

Link to comment
Share on other sites

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