Jump to content

Testing if a Value is a Key / GUID


Love Zhaoying
 Share

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

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

Recommended Posts

Is the information at https://wiki.secondlife.com/wiki/Category:LSL_Key still valid?

Quote:

To test for a valid key, just do this:

if(uuid){ //do something }

I am coding for a situation where:

if (value is a GUID) {

Do stuff

}

else if (value is type ISON_OBJECT) {

Do different stuff

}

else { // Not GUID or JSON_OBJECT

Do yet different stuff

}

 

Link to comment
Share on other sites

1 minute ago, Quistess Alpha said:

Yup, but it only works if the type of the value is key. as per the wiki on the if statement:

Quote

[value type: (key) is] True only if it is a valid key and not NULL_KEY.

https://wiki.secondlife.com/wiki/If

That's the point of my question, I think..

I get a new Key/GUID from llGenerateKey() (https://wiki.secondlife.com/wiki/LlGenerateKey).

Even if the Key/GUID returned from llGenerateKey() is not the Key "of something in Second Life", do you think the if(key) test should always succeed?

 

 

 

Link to comment
Share on other sites

18 minutes ago, Love Zhaoying said:

Even if the Key/GUID returned from llGenerateKey() is not the Key "of something in Second Life", do you think the if(key) test should always succeed?

Yes, as long as llGenerateKey() doesn't fluke and return NULL_KEY,

if(llGenerateKey()){/*always executes*/}else{/*never executes*/}

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, Love Zhaoying said:

If it does, we're all screwed - SL ran out of GUID's!!!

What next?!?? IP Addresses??!

..Is joke!

on the realistic side, for those who might be curious (because I was at one time in the past): Version-4 UUIDs, which are totally random, have approximately 5.3 x 1036 possible values. This number is so large that if you were to generate 1 billion UUIDs per second for 85 years you have a 50% chance of creating a duplicate.   Granted, Second Life uses Version-5 UUIDs which are not truly random, but I can safely extrapolate that the number of keys is comparatively the same. :)

Link to comment
Share on other sites

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