Jump to content

Substitute for llGetCreatorKey


Miranda Freenote

Recommended Posts

I'm working on a script that scans for a certain object by name and sends a message if that object was made by a specific creator. 

 

When I wrote a similar script that checked to see if the object was owned by a specific person I used:

//a bunch of script including a llSensorRepeat

sensor( integer detected )
    {
        if(detected--)
        {
   
          if (llGetOwnerKey(llDetectedKey(0) ) ==  "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

//the XXXX is the UUID of the Owner I was screening for.
//more script followed telling what to do if the object was owned by that avatar.

 

 

 

The above lines of script worked perfectly when screening for an object owned by a certain person, but I'm having trouble converting it to a script that screens by creator name because there is no such command as "llGetCreatorKey". 

I believe that I need to use llGetObjectDetails and OBJECT_CREATOR, but I
have tried dozens of ways of substituting those commands into the above lines of script and I always get errors. 

If someone could tell me what the correct equivilant to llGetCreatorKey is and how it would fit in these lines of script I would appreciate it greatly.

Link to comment
Share on other sites

Presumably you mean there's no "get creator key from name" because there is http://wiki.secondlife.com/wiki/LlGetCreator which returns a key.  However, this isn't much use to you because that's for the prim that the script is running in, rather than one you have detected.

You're on the right lines with llGetObjectDetails but without knowing a bit more about what you're doing and what errors you get it's a bit hard to guess what you're doing wrong.

The trap that you can easily fall into though is to call llKey2Name expecting to then be able to compare name strings.  This will work just fine as long as the avatar is present in the sim (or was recently there), after that, it returns NULL.

To solve this you can call llRequestAgentData or use/hope/rely on an external method to resolve name to key in the first instance and compare that with your returned key.

It would help to know what it is in a broader sense that you're wanting to do though as there may be a better way all round.

Link to comment
Share on other sites

// To check all detected objects   sensor(integer detected)   {      while(detected--)      {         if (llList2Key(llGetObjectDetails(llDetectedKey(detected), [OBJECT_CREATOR]), 0) ==  "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")         {            // You have found an object created by "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"         }      }            }

 

Link to comment
Share on other sites

I like it Innula but that's not by "creator name" which is what was asked for.  I don't know if that's a false requirement or resolved elsewhere?  *shrugs* we didn't have much to go on :matte-motes-frown:

I assumed that it is a script that takes an input name e.g. "John Smith" and tests to see if the object is created by John Smith so the result of the sensor keys would first have to be converted to names, or use a name2key method to convert John Smith to key for your test.

Need more info!

Link to comment
Share on other sites

The OP, though, was complaining that there's no llGetCreatorKey.  I was just saying that we don't need it, since llGetObjectDetails does the same job.

In the example she gave, it looks as if she has the key already, but if not, and we only know the name, then I think something like this (untested) should do the trick.

 

 

 

string lookfor = "Torley Linden";integer i;key  query;list detectedKeys;list detectedNames;string agentUsername(string agentLegacyName) {	return llDumpList2String(llParseString2List(llToLower(agentLegacyName)+" ", [" resident ", " "],[]), ".");}default{	state_entry()	{		lookfor = agentUsername(lookfor);  // so we don't get confused by capitalisation of legacy names, whether to include "Resident" and so on	}	touch_start(integer total_number)	{		detectedKeys=[];		detectedNames=[];		llSensor("","",ACTIVE|PASSIVE,10.0,PI);	}	no_sensor()	{		llOwnerSay("Sorry, couldn't find anything");	}	sensor(integer total_number)	{		i = 0;		do {			detectedKeys+=[llDetectedKey(i)];			detectedNames+=[llDetectedName(i)];		}		while (++i<total_number);		i = -llGetListLength(detectedKeys);		query = llRequestUsername(llList2Key(llGetObjectDetails(llList2Key(detectedKeys,i),[OBJECT_CREATOR]),0));	}	dataserver(key requested, string data)	{		if (query == requested){			if (data == lookfor){				llOwnerSay("The object "+llList2String(detectedNames,i)+" was made by "+lookfor);			}			++i;			if(i){				query = llRequestUsername(llList2Key(llGetObjectDetails(llList2Key(detectedKeys,i),[OBJECT_CREATOR]),0));			}			else{				llOwnerSay("Finished scan");			}		}	}}

 

;
Link to comment
Share on other sites

I apologize if I was too vague. I wrote the original post at 3AM, and I guess I could have been more specific.   I do know the UUID of the creator, I just replaced it with XXXX's in the example because I didn't feel comfortable posting the actual key numbers in the forum.  Perhaps I am being over cautious. 

When I said the scanner searches by name I meant it seaches for an object with a specific name.  For example  it checks to see if there is an object nearby named  " ABC"  and then checks to makes sure that "ABC" is made by a certain person by checking the key of ABC's  creator.  Otherwise, any prankster could drop an object  named ABC near the sensor and set it off.

I had tried some code simmilar to the ones suggested in this thread but didn't have the sytax quite right. I am an amature with code and LSL is picky about where to put commas and parenthesis. 

Anyway, I inserted the code LepreKhaun suggested into my script. 

// To check all detected objects   sensor(integer detected)   {      while(detected--)      {         if (llList2Key(llGetObjectDetails(llDetectedKey(detected), [OBJECT_CREATOR]), 0) ==  "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")         {            // You have found an object created by "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"         }      }            }

 

This is exactly what I needed. 

 

Thank you very much for your help.  :)

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...